collection-crud/src/Entity/Socket.php

44 lines
1.0 KiB
PHP

<?php declare(strict_types=1);
namespace App\Entity;
use App\Enum\SocketTypeEnum;
use Doctrine\ORM\Mapping as ORM;
/**
* @see https://en.wikipedia.org/wiki/CPU_socket
*/
#[ORM\Table(name: 'socket', schema: 'collection')]
#[ORM\Entity]
class Socket {
use GetSetTrait;
#[ORM\Column(name: 'id', type: 'integer', nullable: FALSE)]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
private int $id;
#[ORM\Column(name: 'name', type: 'string', nullable: FALSE)]
private string $name;
#[ORM\Column(name: 'other_name', type: 'string', nullable: TRUE)]
private ?string $otherName = null;
#[ORM\Column(name: 'pin_count', type: 'integer', nullable: FALSE)]
private int $pinCount;
#[ORM\Column(
name: 'socket_type',
type: 'string',
enumType: SocketTypeEnum::class,
)]
private SocketTypeEnum $type = SocketTypeEnum::PIN_GRID_ARRAY;
public function __toString(): string
{
$name = ( ! empty($this->otherName)) ? "$this->name/$this->otherName" : $this->name;
return "$name ($this->type->value $this->pinCount)";
}
}