]> git.mxchange.org Git - friendica.git/blob - src/Core/Worker/Factory/Process.php
Fixup command argument
[friendica.git] / src / Core / Worker / Factory / Process.php
1 <?php
2
3 namespace Friendica\Core\Worker\Factory;
4
5 use Friendica\BaseFactory;
6 use Friendica\Capabilities\ICanCreateFromTableRow;
7 use Friendica\Core\Worker\Entity;
8
9 class Process extends BaseFactory implements ICanCreateFromTableRow
10 {
11         public function createFromTableRow(array $row): Entity\Process
12         {
13                 return new Entity\Process(
14                         $row['pid'],
15                         $row['command'],
16                         new \DateTime($row['created'] ?? 'now', new \DateTimeZone('UTC'))
17                 );
18         }
19
20         /**
21          * Creates a new process entry for a given PID
22          *
23          * @param int    $pid
24          * @param string $command
25          *
26          * @return Entity\Process
27          */
28         public function create(int $pid, string $command): Entity\Process
29         {
30                 return $this->createFromTableRow([
31                         'pid'     => $pid,
32                         'command' => $command,
33                 ]);
34         }
35 }