src/Entity/CronTask.php line 11
<?phpnamespace App\Entity;use App\Repository\CronTaskRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: CronTaskRepository::class)]#[ORM\Table(name: 'cron_task')]class CronTask{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]private ?int $id = null;#[ORM\Column(length: 100, unique: true)]private ?string $name = null;#[ORM\Column(length: 255)]private ?string $description = null;#[ORM\Column(length: 255)]private ?string $command = null;#[ORM\Column]private ?bool $enabled = true;#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]private ?\DateTimeInterface $lastRun = null;#[ORM\Column(nullable: true)]private ?int $lastDuration = null;#[ORM\Column(length: 50, nullable: true)]private ?string $lastStatus = null;#[ORM\Column(type: Types::TEXT, nullable: true)]private ?string $lastOutput = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTimeInterface $createdAt = null;#[ORM\Column(type: Types::DATETIME_MUTABLE)]private ?\DateTimeInterface $updatedAt = null;public function __construct(){$this->createdAt = new \DateTime();$this->updatedAt = new \DateTime();}public function getId(): ?int{return $this->id;}public function getName(): ?string{return $this->name;}public function setName(string $name): static{$this->name = $name;$this->updatedAt = new \DateTime();return $this;}public function getDescription(): ?string{return $this->description;}public function setDescription(string $description): static{$this->description = $description;$this->updatedAt = new \DateTime();return $this;}public function getCommand(): ?string{return $this->command;}public function setCommand(string $command): static{$this->command = $command;$this->updatedAt = new \DateTime();return $this;}public function isEnabled(): ?bool{return $this->enabled;}public function setEnabled(bool $enabled): static{$this->enabled = $enabled;$this->updatedAt = new \DateTime();return $this;}public function getLastRun(): ?\DateTimeInterface{return $this->lastRun;}public function setLastRun(?\DateTimeInterface $lastRun): static{$this->lastRun = $lastRun;$this->updatedAt = new \DateTime();return $this;}public function getLastDuration(): ?int{return $this->lastDuration;}public function setLastDuration(?int $lastDuration): static{$this->lastDuration = $lastDuration;$this->updatedAt = new \DateTime();return $this;}public function getLastStatus(): ?string{return $this->lastStatus;}public function setLastStatus(?string $lastStatus): static{$this->lastStatus = $lastStatus;$this->updatedAt = new \DateTime();return $this;}public function getLastOutput(): ?string{return $this->lastOutput;}public function setLastOutput(?string $lastOutput): static{$this->lastOutput = $lastOutput;$this->updatedAt = new \DateTime();return $this;}public function getCreatedAt(): ?\DateTimeInterface{return $this->createdAt;}public function setCreatedAt(\DateTimeInterface $createdAt): static{$this->createdAt = $createdAt;return $this;}public function getUpdatedAt(): ?\DateTimeInterface{return $this->updatedAt;}public function setUpdatedAt(\DateTimeInterface $updatedAt): static{$this->updatedAt = $updatedAt;return $this;}/*** Retourne le statut formaté pour l'affichage*/public function getFormattedStatus(): string{return match($this->lastStatus) {'success' => '✅ Succès','error' => '❌ Erreur',default => '⏳ En attente'};}/*** Retourne la durée formatée*/public function getFormattedDuration(): string{if (!$this->lastDuration) {return 'N/A';}if ($this->lastDuration < 60) {return $this->lastDuration . 's';}$minutes = floor($this->lastDuration / 60);$seconds = $this->lastDuration % 60;return $minutes . 'm ' . $seconds . 's';}}