]> git.mxchange.org Git - friendica.git/blob - src/Core/Worker/Entity/Process.php
Refactor Process for new paradigm
[friendica.git] / src / Core / Worker / Entity / Process.php
1 <?php
2
3 namespace Friendica\Core\Worker\Entity;
4
5 use DateTime;
6 use Friendica\BaseEntity;
7
8 /**
9  * @property-read int $pid
10  * @property-read string $command
11  * @property-read DateTime $created
12  */
13 class Process extends BaseEntity
14 {
15         /** @var int */
16         protected $pid;
17         /** @var string */
18         protected $command;
19         /** @var DateTime */
20         protected $created;
21
22         /**
23          * @param int       $pid
24          * @param string    $command
25          * @param DateTime $created
26          */
27         public function __construct(int $pid, string $command, DateTime $created)
28         {
29                 $this->pid     = $pid;
30                 $this->command = $command;
31                 $this->created = $created;
32         }
33
34         /**
35          * Returns a new Process with the given PID
36          *
37          * @param int $pid
38          *
39          * @return $this
40          * @throws \Exception
41          */
42         public function withPid(int $pid): Process
43         {
44                 return new static($pid, $this->command, new DateTime('now', new \DateTimeZone('URC')));
45         }
46 }