1 | <?php |
||
24 | class Result |
||
25 | { |
||
26 | /** |
||
27 | * Command that got executed. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private $cmd; |
||
32 | |||
33 | /** |
||
34 | * Result code. |
||
35 | * |
||
36 | * @var int |
||
37 | */ |
||
38 | private $code; |
||
39 | |||
40 | /** |
||
41 | * List of valid exit codes. |
||
42 | * |
||
43 | * @var int[] |
||
44 | */ |
||
45 | private $validExitCodes; |
||
46 | |||
47 | /** |
||
48 | * Output buffer. |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | private $buffer; |
||
53 | |||
54 | /** |
||
55 | * StdOut. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | private $stdOut; |
||
60 | |||
61 | /** |
||
62 | * StdErr. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | private $stdErr; |
||
67 | |||
68 | /** |
||
69 | * Path where the output is redirected to. |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | private $redirectPath; |
||
74 | |||
75 | /** |
||
76 | * Result constructor. |
||
77 | * |
||
78 | * @param string $cmd |
||
79 | * @param int $code |
||
80 | * @param string $stdOut |
||
81 | * @param string $stdErr |
||
82 | * @param string $redirectPath |
||
83 | 30 | * @param int[] $validExitCodes |
|
84 | */ |
||
85 | public function __construct( |
||
100 | |||
101 | /** |
||
102 | * Cmd getter. |
||
103 | * |
||
104 | * @return string |
||
105 | 2 | */ |
|
106 | public function getCmd(): string |
||
110 | |||
111 | /** |
||
112 | * Code getter. |
||
113 | * |
||
114 | * @return int |
||
115 | 5 | */ |
|
116 | public function getCode(): int |
||
120 | |||
121 | /** |
||
122 | * Command executed successful. |
||
123 | 6 | */ |
|
124 | public function isSuccessful(): bool |
||
128 | |||
129 | /** |
||
130 | * StdOutput getter. |
||
131 | * |
||
132 | * @return string |
||
133 | 4 | */ |
|
134 | public function getStdOut(): string |
||
138 | |||
139 | /** |
||
140 | * StdError getter. |
||
141 | * |
||
142 | * @return string |
||
143 | 5 | */ |
|
144 | public function getStdErr(): string |
||
148 | |||
149 | /** |
||
150 | * Is the output redirected to a file. |
||
151 | * |
||
152 | * @return bool |
||
153 | 4 | */ |
|
154 | public function isOutputRedirected(): bool |
||
158 | |||
159 | /** |
||
160 | * Return path to the file where the output is redirected to. |
||
161 | * |
||
162 | * @return string |
||
163 | 4 | */ |
|
164 | public function getRedirectPath(): string |
||
168 | |||
169 | /** |
||
170 | * Return the output as array. |
||
171 | * |
||
172 | * @return array |
||
173 | 4 | */ |
|
174 | public function getStdOutAsArray(): array |
||
181 | |||
182 | /** |
||
183 | * Converts a string into an array. |
||
184 | * |
||
185 | * @return array |
||
186 | 4 | */ |
|
187 | private function textToBuffer(): array |
||
191 | |||
192 | /** |
||
193 | * Magic to string method. |
||
194 | * |
||
195 | * @return string |
||
196 | 1 | */ |
|
197 | public function __toString(): string |
||
201 | } |
||
202 |