src/Entity/CompanyIndicator.php line 9
<?php
namespace App\Entity;
use App\Repository\CompanyIndicatorRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CompanyIndicatorRepository::class)]
class CompanyIndicator
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false)]
private ?Indicator $indicator = null;
#[ORM\Column(length: 20, nullable: true)]
private ?string $value = null;
#[ORM\Column(length: 20, nullable: true)]
private ?string $target = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $updated = null;
#[ORM\ManyToOne(inversedBy: 'companyIndicators')]
#[ORM\JoinColumn(nullable: false)]
private ?CompanyIndicatorThematic $companyIndicatorThematic = null;
public function __construct(Indicator $indicator = null, CompanyIndicatorThematic $companyIndicatorThematic = null)
{
$this->indicator = $indicator;
$this->companyIndicatorThematic = $companyIndicatorThematic;
}
public function getId(): ?int
{
return $this->id;
}
public function getIndicator(): ?Indicator
{
return $this->indicator;
}
public function setIndicator(?Indicator $indicator): self
{
$this->indicator = $indicator;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(?string $value): self
{
$this->value = $value;
return $this;
}
public function getTarget(): ?string
{
return $this->target;
}
public function setTarget(?string $target): self
{
$this->target = $target;
return $this;
}
public function getUpdated(): ?\DateTimeImmutable
{
return $this->updated;
}
public function setUpdated(\DateTimeImmutable $updated): self
{
$this->updated = $updated;
return $this;
}
public function getCompanyIndicatorThematic(): ?CompanyIndicatorThematic
{
return $this->companyIndicatorThematic;
}
public function setCompanyIndicatorThematic(?CompanyIndicatorThematic $companyIndicatorThematic): self
{
$this->companyIndicatorThematic = $companyIndicatorThematic;
return $this;
}
public function getStatus(): array
{
if (!$this->target || !$this->value) {
$color = "black";
$status = "notmesured";
} else if (!$this->indicator->isReverse()) {
if ($this->value < $this->target) {
$color = "late";
$status = "notreached";
} else {
$color = "terminated";
$status = "reached";
}
} else {
if ($this->value <= $this->target) {
$color = "terminated";
$status = "reached";
} else {
$color = "late";
$status = "notreached";
}
}
return ["status" => $status, "color" => $color];
}
}