Jobs setup

This commit is contained in:
2023-06-12 21:14:07 -04:00
parent 03c1dac2f2
commit 88f91c4bd5
60 changed files with 965 additions and 495 deletions

View File

@ -25,24 +25,20 @@ class Job implements Model
{
return $this->arguments ?? '';
}
public function isExecuted(): bool
{
return $this->lastState()->getStatus() === State\Job::Executed;
}
public function setId(int $id): Job
{
$this->id = $id;
return $this;
}
public function setCommand(string $message): Job
public function setCommand(string $command): Job
{
$this->message = $message;
$this->command = $command;
return $this;
}
public function setArguments(string $dateTime): Job
public function setArguments(string $arguments): Job
{
$this->dateTime = $dateTime;
$this->arguments = $arguments;
return $this;
}
@ -82,10 +78,14 @@ class Job implements Model
return $this;
}
public function isExecuted(): bool
{
return $this->lastState()->getStatus() === State\Job::Executed;
}
public function lastState(): State\Job
{
if (count($this->getStates()) === 0) {
throw new Stateless($this);
throw new Stateless($this->getId());
}
return $this->getStates()[array_key_last($this->getStates())];
}
@ -94,9 +94,9 @@ class Job implements Model
{
return [
'id' => $this->getId(),
'message' => $this->getMessage()->toArray(),
'date_time' => $this->getDateTime()->format('Y-m-d H:i:s'),
'executed' => $this->isExecuted()
'command' => $this->getCommand(),
'arguments' => $this->getArguments(),
'states' => $this->getStates()
];
}
public function jsonSerialize(): mixed