1 | <?php |
||
20 | trait ProcessTrait |
||
21 | { |
||
22 | /** |
||
23 | * @var ProcessFactory |
||
24 | */ |
||
25 | private $processFactory; |
||
26 | |||
27 | /** |
||
28 | * @param ProcessFactory $processFactory |
||
29 | * |
||
30 | * @return $this |
||
31 | */ |
||
32 | 79 | public function setProcessFactory(ProcessFactory $processFactory) |
|
38 | |||
39 | /** |
||
40 | * @return ProcessFactory |
||
41 | */ |
||
42 | 65 | public function getProcessFactory() |
|
43 | { |
||
44 | 65 | if (!$this->processFactory) { |
|
45 | 18 | $this->processFactory = new ProcessFactory(); |
|
46 | 18 | } |
|
47 | |||
48 | 65 | return $this->processFactory; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param string $commandline The command line to run |
||
53 | * @param string|null $cwd The working directory or null to use the working dir of the current PHP |
||
54 | * process |
||
55 | * @param array|null $env The environment variables or null to inherit |
||
56 | * @param string|null $input The input |
||
57 | * @param int|float|null $timeout The timeout in seconds or null to disable |
||
58 | * @param array $options An array of options for proc_open |
||
59 | * |
||
60 | * @return Process |
||
61 | * @throws RuntimeException When proc_open is not installed |
||
62 | */ |
||
63 | 65 | public function getProcess( |
|
74 | |||
75 | /** |
||
76 | * Abstract Log function that might should be handed by the OptionalLoggerTrait or similar |
||
77 | * |
||
78 | * @param string $level |
||
79 | * @param string $message |
||
80 | * @param array $context |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | abstract protected function log($level, $message, array $context = []); |
||
85 | } |
||
86 |