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 | * Get the binary version |
||
104 | * |
||
105 | * @return mixed |
||
106 | */ |
||
107 | public function getBinaryVersion() |
||
111 | |||
112 | /** |
||
113 | * Executes a command |
||
114 | * |
||
115 | * @param string $cmd the command to execute |
||
116 | * @param bool $git if the command is git or a generic command |
||
117 | 99 | * @param null $cwd the directory where the command must be executed |
|
118 | * @param array $acceptedExitCodes exit codes accepted to consider the command execution successful |
||
119 | 99 | * |
|
120 | 99 | * @throws \RuntimeException |
|
121 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
122 | * @throws \Symfony\Component\Process\Exception\ProcessTimedOutException |
||
123 | 99 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
124 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
125 | 99 | * @return Caller |
|
126 | */ |
||
127 | public function execute($cmd, $git = true, $cwd = null, $acceptedExitCodes = array(0)) |
||
156 | |||
157 | /** |
||
158 | * returns the output of the last executed command |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | public function getOutput() |
||
166 | 91 | ||
167 | 81 | /** |
|
168 | 81 | * returns the output of the last executed command as an array of lines |
|
169 | 81 | * |
|
170 | 81 | * @param bool $stripBlankLines remove the blank lines |
|
171 | * |
||
172 | * @return array |
||
173 | */ |
||
174 | 81 | public function getOutputLines($stripBlankLines = false) |
|
189 | |||
190 | /** |
||
191 | * Get RawOutput |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getRawOutput() |
||
199 | |||
200 | /** |
||
201 | * returns the error output of the last executed command |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | public function getErrorOutput() |
||
209 | |||
210 | /** |
||
211 | * returns the error output of the last executed command as an array of lines |
||
212 | * |
||
213 | * @param bool $stripBlankLines remove the blank lines |
||
214 | * |
||
215 | * @return array |
||
216 | */ |
||
217 | public function getErrorLines($stripBlankLines = false) |
||
232 | |||
233 | /** |
||
234 | * Get RawErrorOutput |
||
235 | * |
||
236 | * @return string |
||
237 | */ |
||
238 | public function getRawErrorOutput() |
||
242 | } |
||
243 |