| Total Complexity | 3 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | abstract class Program implements Lifecycle |
||
| 16 | { |
||
| 17 | use Forking; |
||
| 18 | |||
| 19 | // use ON process started |
||
| 20 | public const STARTED = 0xE1; |
||
| 21 | |||
| 22 | // use ON process stopped |
||
| 23 | public const STOPPED = 0xE9; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var string |
||
| 27 | */ |
||
| 28 | protected $name = null; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return string |
||
| 32 | */ |
||
| 33 | final public function name() : string |
||
| 34 | { |
||
| 35 | return $this->name; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @return static |
||
| 40 | */ |
||
| 41 | final public function fork() |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param Piping $piping |
||
| 48 | * @return static |
||
| 49 | */ |
||
| 50 | final public function forked(Piping $piping) : self |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * triggered when process forking (still in parent process) |
||
| 58 | * @param Piping $piping |
||
| 59 | */ |
||
| 60 | abstract protected function forking(Piping $piping) : void; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * triggered when process started (in child process) |
||
| 64 | */ |
||
| 65 | abstract protected function starting() : void; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * triggered when process exiting (in child process) |
||
| 69 | * @param Promised $wait |
||
| 70 | */ |
||
| 71 | abstract protected function stopping(Promised $wait) : void; |
||
| 72 | } |
||
| 73 |