<?php
namespace App\Entity\Server\Hetzner;
use App\Entity\BaseEntity;
use App\Repository\Server\Hetzner\ServerTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Entity(repositoryClass: ServerTypeRepository::class)]
#[ORM\Table(name: '`hetzner_sell_server_server_type`')]
class ServerType extends BaseEntity
{
#[ORM\Id]
#[ORM\Column(type: 'guid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private $id;
#[ORM\Column(length: 255, nullable: true)]
private ?string $systemId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $description = null;
#[ORM\Column]
private ?int $cores = null;
#[ORM\Column]
private ?float $memory = null;
#[ORM\Column]
private ?float $disk = null;
#[ORM\Column]
private ?bool $isDeprecated = null;
public string $hourlyPrice;
public string $monthlyPrice;
#[ORM\Column(length: 255, nullable: true)]
private ?string $storageType = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $cpuType = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $architecture = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $deprecation = null;
#[ORM\OneToMany(mappedBy: 'serverType', targetEntity: ServerTypePrice::class)]
private Collection $serverTypePrices;
#[ORM\OneToMany(mappedBy: 'serverType', targetEntity: Server::class)]
private Collection $servers;
#[ORM\OneToMany(mappedBy: 'serverType', targetEntity: DataCenterSupportedServerTypes::class)]
private Collection $dataCenterSupportedServerTypes;
public function __construct()
{
parent::__construct();
$this->serverTypePrices = new ArrayCollection();
$this->servers = new ArrayCollection();
$this->dataCenterSupportedServerTypes = new ArrayCollection();
}
public function __toString()
{
return
'Cpu : '.$this->cpuType
. ' - '
.'Core : ' . $this->getCores()
. ' - '
.'Memory : '.$this->getMemory();
}
public function getId(): ?string
{
return $this->id;
}
public function getSystemId(): ?string
{
return $this->systemId;
}
public function setSystemId(?string $systemId): static
{
$this->systemId = $systemId;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getCores(): ?int
{
return $this->cores;
}
public function setCores(int $cores): static
{
$this->cores = $cores;
return $this;
}
public function getMemory(): ?float
{
return $this->memory;
}
public function setMemory(float $memory): static
{
$this->memory = $memory;
return $this;
}
public function getDisk(): ?float
{
return $this->disk;
}
public function setDisk(float $disk): static
{
$this->disk = $disk;
return $this;
}
public function isIsDeprecated(): ?bool
{
return $this->isDeprecated;
}
public function setIsDeprecated(bool $isDeprecated): static
{
$this->isDeprecated = $isDeprecated;
return $this;
}
public function getStorageType(): ?string
{
return $this->storageType;
}
public function setStorageType(?string $storageType): static
{
$this->storageType = $storageType;
return $this;
}
public function getCpuType(): ?string
{
return $this->cpuType;
}
public function setCpuType(?string $cpuType): static
{
$this->cpuType = $cpuType;
return $this;
}
public function getArchitecture(): ?string
{
return $this->architecture;
}
public function setArchitecture(?string $architecture): static
{
$this->architecture = $architecture;
return $this;
}
public function getDeprecation(): ?\DateTimeInterface
{
return $this->deprecation;
}
public function setDeprecation(?\DateTimeInterface $deprecation): static
{
$this->deprecation = $deprecation;
return $this;
}
/**
* @return Collection<int, ServerTypePrice>
*/
public function getServerTypePrices(): Collection
{
return $this->serverTypePrices;
}
public function addServerTypePrice(ServerTypePrice $serverTypePrice): static
{
if (!$this->serverTypePrices->contains($serverTypePrice)) {
$this->serverTypePrices->add($serverTypePrice);
$serverTypePrice->setServerType($this);
}
return $this;
}
public function removeServerTypePrice(ServerTypePrice $serverTypePrice): static
{
if ($this->serverTypePrices->removeElement($serverTypePrice)) {
// set the owning side to null (unless already changed)
if ($serverTypePrice->getServerType() === $this) {
$serverTypePrice->setServerType(null);
}
}
return $this;
}
/**
* @return Collection<int, Server>
*/
public function getServers(): Collection
{
return $this->servers;
}
public function addServer(Server $server): static
{
if (!$this->servers->contains($server)) {
$this->servers->add($server);
$server->setServerType($this);
}
return $this;
}
public function removeServer(Server $server): static
{
if ($this->servers->removeElement($server)) {
// set the owning side to null (unless already changed)
if ($server->getServerType() === $this) {
$server->setServerType(null);
}
}
return $this;
}
/**
* @return Collection<int, DataCenterSupportedServerTypes>
*/
public function getDataCenterSupportedServerTypes(): Collection
{
return $this->dataCenterSupportedServerTypes;
}
public function addDataCenterSupportedServerType(DataCenterSupportedServerTypes $dataCenterSupportedServerType): static
{
if (!$this->dataCenterSupportedServerTypes->contains($dataCenterSupportedServerType)) {
$this->dataCenterSupportedServerTypes->add($dataCenterSupportedServerType);
$dataCenterSupportedServerType->setServerType($this);
}
return $this;
}
public function removeDataCenterSupportedServerType(DataCenterSupportedServerTypes $dataCenterSupportedServerType): static
{
if ($this->dataCenterSupportedServerTypes->removeElement($dataCenterSupportedServerType)) {
// set the owning side to null (unless already changed)
if ($dataCenterSupportedServerType->getServerType() === $this) {
$dataCenterSupportedServerType->setServerType(null);
}
}
return $this;
}
public function getMonthlyPrice(): string
{
return $this->monthlyPrice;
}
public function setMonthlyPrice(string $monthlyPrice): void
{
$this->monthlyPrice = $monthlyPrice;
}
public function getHourlyPrice(): string
{
return $this->hourlyPrice;
}
public function setHourlyPrice(string $hourlyPrice): void
{
$this->hourlyPrice = $hourlyPrice;
}
}