1 | <?php |
||
31 | class Caller implements CallerInterface |
||
32 | { |
||
33 | /** |
||
34 | * GitBinary instance |
||
35 | * |
||
36 | * @var \GitElephant\GitBinary |
||
37 | */ |
||
38 | private $binary; |
||
39 | |||
40 | /** |
||
41 | * the repository path |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | private $repositoryPath; |
||
46 | |||
47 | /** |
||
48 | * the output lines of the command |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | private $outputLines = array(); |
||
53 | |||
54 | /** |
||
55 | * raw output |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | private $rawOutput; |
||
60 | |||
61 | /** |
||
62 | * the output lines of the command |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | private $errorLines = array(); |
||
67 | |||
68 | /** |
||
69 | * raw output |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | private $rawErrorOutput; |
||
74 | |||
75 | /** |
||
76 | * Class constructor |
||
77 | * |
||
78 | * @param \GitElephant\GitBinary $binary the binary |
||
79 | * @param string $repositoryPath the physical base path for the repository |
||
80 | */ |
||
81 | 105 | public function __construct(GitBinary $binary, $repositoryPath) |
|
91 | |||
92 | /** |
||
93 | * Get the binary path |
||
94 | * |
||
95 | * @return mixed |
||
96 | */ |
||
97 | 1 | public function getBinaryPath() |
|
101 | |||
102 | /** |
||
103 | * Executes a command |
||
104 | * |
||
105 | * @param string $cmd the command to execute |
||
106 | * @param bool $git if the command is git or a generic command |
||
107 | * @param null $cwd the directory where the command must be executed |
||
108 | * @param array $acceptedExitCodes exit codes accepted to consider the command execution successful |
||
109 | * |
||
110 | * @throws \RuntimeException |
||
111 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
112 | * @throws \Symfony\Component\Process\Exception\ProcessTimedOutException |
||
113 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
114 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
115 | * @return Caller |
||
116 | */ |
||
117 | 99 | public function execute($cmd, $git = true, $cwd = null, $acceptedExitCodes = array(0)) |
|
146 | |||
147 | /** |
||
148 | * returns the output of the last executed command |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | 2 | public function getOutput() |
|
156 | |||
157 | /** |
||
158 | * returns the output of the last executed command as an array of lines |
||
159 | * |
||
160 | * @param bool $stripBlankLines remove the blank lines |
||
161 | * |
||
162 | * @return array |
||
163 | */ |
||
164 | 91 | public function getOutputLines($stripBlankLines = false) |
|
179 | |||
180 | /** |
||
181 | * Get RawOutput |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | 1 | public function getRawOutput() |
|
189 | |||
190 | /** |
||
191 | * returns the error output of the last executed command |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getErrorOutput() |
||
199 | |||
200 | /** |
||
201 | * returns the error output of the last executed command as an array of lines |
||
202 | * |
||
203 | * @param bool $stripBlankLines remove the blank lines |
||
204 | * |
||
205 | * @return array |
||
206 | */ |
||
207 | public function getErrorLines($stripBlankLines = false) |
||
222 | |||
223 | /** |
||
224 | * Get RawErrorOutput |
||
225 | * |
||
226 | * @return string |
||
227 | */ |
||
228 | public function getRawErrorOutput() |
||
232 | } |
||
233 |