collection-crud/src/Entity/Cpu.php

129 lines
3.4 KiB
PHP
Raw Normal View History

2022-10-13 22:26:33 -04:00
<?php declare(strict_types=1);
namespace App\Entity;
2022-10-27 11:55:16 -04:00
use App\Enum\CpuArchitectureEnum;
2022-10-20 11:07:27 -04:00
use Doctrine\Common\Collections\{Collection, ArrayCollection};
2022-10-13 22:26:33 -04:00
use Doctrine\ORM\Mapping as ORM;
2022-10-27 11:55:16 -04:00
#[ORM\Table('cpu', schema: 'collection')]
2022-10-13 22:26:33 -04:00
#[ORM\Entity]
class Cpu {
2022-10-28 08:46:35 -04:00
use CpuCacheTrait;
2022-10-13 22:26:33 -04:00
use GetSetTrait;
2022-10-27 11:55:16 -04:00
#[ORM\Column('id', type: 'integer', nullable: FALSE)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
2022-10-13 22:26:33 -04:00
2022-10-25 14:52:58 -04:00
#[ORM\ManyToOne(targetEntity: 'Brand', fetch: 'EAGER')]
#[ORM\OrderBy(['name' => 'asc'])]
2022-10-27 11:55:16 -04:00
#[ORM\JoinColumn('brand_id', referencedColumnName: 'id', nullable: FALSE)]
private Brand $brand;
2022-10-20 11:07:27 -04:00
2022-10-27 11:55:16 -04:00
#[ORM\Column('architecture', type: 'string', enumType: CpuArchitectureEnum::class)]
2022-10-28 08:46:35 -04:00
private CpuArchitectureEnum $architecture;
2022-10-27 11:55:16 -04:00
2022-10-20 11:07:27 -04:00
/**
* @var Collection<int, Socket>
*/
#[ORM\ManyToMany(targetEntity: Socket::class)]
2022-10-27 11:55:16 -04:00
#[ORM\JoinTable('collection.cpu_socket_link')]
2022-10-31 21:12:48 -04:00
#[ORM\JoinColumn('cpu_id', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn('socket_id', referencedColumnName: 'id')]
2022-10-20 11:07:27 -04:00
#[ORM\OrderBy(['name' => 'asc'])]
private Collection $sockets;
2022-10-27 11:55:16 -04:00
#[ORM\Column('product_line', type: 'string')]
private string $productLine;
#[ORM\Column('model', type: 'string')]
private string $model;
#[ORM\Column('part_number', type: 'string')]
private string $partNumber;
#[ORM\Column('lot_number', type: 'string', nullable: TRUE, options: array(
'comment' => 'The CPU lot number, such as s-spec for Intel CPUs'
))]
private ?string $lotNumber;
2022-10-28 08:46:35 -04:00
#[ORM\Column('micro_architecture', type: 'string', nullable: TRUE)]
private ?string $microArchitecture = '';
2022-10-27 11:55:16 -04:00
2022-10-28 08:46:35 -04:00
#[ORM\Column('codename', type: 'string', nullable: TRUE)]
private ?string $codeName = '';
2022-10-27 11:55:16 -04:00
#[ORM\Column('base_speed', type: 'integer', options: array(
'comment' => 'The stock speed of the cpu in MHz'
))]
private int $baseSpeed;
#[ORM\Column('boost_speed', type: 'integer', nullable: true, options: array(
'comment' => 'The max boost speed of the cpu in MHz, if applicable'
))]
private ?int $boostSpeed;
#[ORM\Column('cores', type: 'integer')]
private int $cores = 1;
#[ORM\Column('threads', type: 'integer')]
private int $threads = 1;
#[ORM\Column('igp', type: 'string', nullable: true, options: array(
'comment' => 'The name of the integrated graphics processor'
))]
private ?string $igp;
#[ORM\Column('voltage', type: 'float', nullable: true)]
private ?float $voltage;
2022-10-28 08:46:35 -04:00
#[ORM\Column('tdp', type: 'integer', nullable: true)]
2022-10-27 11:55:16 -04:00
private ?int $tdp;
#[ORM\Column('process_node', type: 'integer', nullable: TRUE)]
private ?int $processNode;
#[ORM\Column('count', type: 'integer')]
private int $count = 1;
#[ORM\Column('usable', type: 'boolean', options: array(
'comment' => 'Whether the chip is working, and can be used with other hardware I have'
))]
private bool $usable = true;
#[ORM\Column('received', type: 'boolean', options: array(
'comment' => "Whether I have the chip in my possession (instead of in shipping)"
))]
private bool $received = true;
#[ORM\Column('link', type: 'string')]
private string $link;
2022-10-28 08:46:35 -04:00
#[ORM\Column('notes', type: 'text', nullable: true)]
private ?string $notes = '';
2022-10-27 11:55:16 -04:00
2022-10-20 11:07:27 -04:00
public function __construct()
{
$this->sockets = new ArrayCollection();
}
public function addSocket(Socket $socket): self
{
if ( ! $this->sockets->contains($socket))
{
$this->sockets->add($socket);
}
return $this;
}
public function removeSocket(Socket $socket): self
{
$this->sockets->removeElement($socket);
return $this;
}
2022-10-13 22:26:33 -04:00
}