src/Entity/Project.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Uid\Uuid;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity
  10.  */
  11. class Project
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\Column(type="integer")
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     private ?int $id null;
  19.     /**
  20.      * @ORM\Column(type="uuid", unique=true, nullable=false)
  21.      */
  22.     private Uuid $uuid;
  23.     /**
  24.      * @ORM\Column(type="string", nullable=false)
  25.      */
  26.     private ?string $name null;
  27.     #[Assert\Range(min0.01max1.00)]
  28.     /**
  29.      * @ORM\Column(type="decimal", nullable=false, precision=3, scale=2)
  30.      */
  31.     private ?float $electricityCostPerUnit null;
  32.     /**
  33.      * @ORM\Column(type="integer", nullable=false, options={"default":0})
  34.      */
  35.     private int $totalElectricitySavingsPerYear 0;
  36.     /**
  37.      * @ORM\Column(type="decimal", nullable=false, precision=8, scale=2, options={"default":"0.00"})
  38.      * @Assert\GreaterThanOrEqual(0)
  39.      * @Assert\LessThan(999999.99)
  40.      */
  41.     private float $totalFinancialSavingsPerYear 0;
  42.     /**
  43.      * @ORM\Column(type="decimal", nullable=false, precision=5, scale=2, options={"default":"0.00"})
  44.      * @Assert\GreaterThanOrEqual(0)
  45.      * @Assert\LessThan(999.99)
  46.      */
  47.     private float $yearsToBreakEven 0;
  48.     /**
  49.      * @ORM\Column(type="decimal", nullable=true, precision=8, scale=2, options={"default":"0.00"})
  50.      * @Assert\GreaterThanOrEqual(0)
  51.      * @Assert\LessThan(999999.99)
  52.      */
  53.     private ?float $totalInvestment;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity="App\Entity\EquipmentSet", mappedBy="project", orphanRemoval=true, cascade={"persist"})
  56.      */
  57.     private Collection $equipmentSets;
  58.     /**
  59.      * @ORM\ManyToOne(targetEntity="App\Entity\Organization", inversedBy="projects")
  60.      * @ORM\JoinColumn(name="organization_id", referencedColumnName="id", nullable=false)
  61.      */
  62.     private ?Organization $organization null;
  63.     public function __construct(Organization $organization)
  64.     {
  65.         $this->uuid Uuid::v1();
  66.         $this->equipmentSets = new ArrayCollection();
  67.         $this->organization $organization;
  68.         $this->electricityCostPerUnit $organization->getDefaultElectricityCostPerUnit();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getUuid(): Uuid
  75.     {
  76.         return $this->uuid;
  77.     }
  78.     public function getName(): ?string
  79.     {
  80.         return $this->name;
  81.     }
  82.     public function setName(string $name): self
  83.     {
  84.         $this->name $name;
  85.         return $this;
  86.     }
  87.     public function getElectricityCostPerUnit(): ?string
  88.     {
  89.         return $this->electricityCostPerUnit;
  90.     }
  91.     public function setElectricityCostPerUnit(string $electricityCostPerUnit): self
  92.     {
  93.         $this->electricityCostPerUnit $electricityCostPerUnit;
  94.         return $this;
  95.     }
  96.     public function getTotalElectricitySavingsPerYear(): ?int
  97.     {
  98.         return $this->totalElectricitySavingsPerYear;
  99.     }
  100.     public function setTotalElectricitySavingsPerYear(int $totalElectricitySavingsPerYear): self
  101.     {
  102.         $this->totalElectricitySavingsPerYear $totalElectricitySavingsPerYear;
  103.         return $this;
  104.     }
  105.     public function getTotalFinancialSavingsPerYear(): ?string
  106.     {
  107.         return $this->totalFinancialSavingsPerYear;
  108.     }
  109.     public function setTotalFinancialSavingsPerYear(string $totalFinancialSavingsPerYear): self
  110.     {
  111.         $this->totalFinancialSavingsPerYear $totalFinancialSavingsPerYear;
  112.         return $this;
  113.     }
  114.     public function getYearsToBreakEven(): ?string
  115.     {
  116.         return $this->yearsToBreakEven;
  117.     }
  118.     public function setYearsToBreakEven(string $yearsToBreakEven): self
  119.     {
  120.         $this->yearsToBreakEven $yearsToBreakEven;
  121.         return $this;
  122.     }
  123.     /**
  124.      * @return Collection|EquipmentSet[]
  125.      */
  126.     public function getEquipmentSets(): array|Collection
  127.     {
  128.         return $this->equipmentSets;
  129.     }
  130.     public function addEquipmentSet(EquipmentSet $equipmentSet): self
  131.     {
  132.         if (!$this->equipmentSets->contains($equipmentSet)) {
  133.             $this->equipmentSets[] = $equipmentSet;
  134.             $equipmentSet->setProject($this);
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeEquipmentSet(EquipmentSet $equipmentSet): self
  139.     {
  140.         $this->equipmentSets->removeElement($equipmentSet);
  141.         return $this;
  142.     }
  143.     public function getOrganization(): ?Organization
  144.     {
  145.         return $this->organization;
  146.     }
  147.     public function setOrganization(Organization $organization): self
  148.     {
  149.         $this->organization $organization;
  150.         return $this;
  151.     }
  152.     public function getTotalInvestment()
  153.     {
  154.         return $this->totalInvestment;
  155.     }
  156.     public function setTotalInvestment($totalInvestment): void
  157.     {
  158.         $this->totalInvestment $totalInvestment;
  159.     }
  160. }