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 | 107 | public function __construct(GitBinary $binary, $repositoryPath) |
|
91 | |||
92 | /** |
||
93 | * @inheritdoc |
||
94 | */ |
||
95 | 1 | public function getBinaryPath() |
|
99 | |||
100 | /** |
||
101 | * @inheritdoc |
||
102 | */ |
||
103 | 96 | public function getBinaryVersion() |
|
107 | |||
108 | /** |
||
109 | * Executes a command |
||
110 | * |
||
111 | * @param string $cmd the command to execute |
||
112 | * @param bool $git if the command is git or a generic command |
||
113 | * @param null $cwd the directory where the command must be executed |
||
114 | * @param array $acceptedExitCodes exit codes accepted to consider the command execution successful |
||
115 | * |
||
116 | * @throws \RuntimeException |
||
117 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
||
118 | * @throws \Symfony\Component\Process\Exception\ProcessTimedOutException |
||
119 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
120 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
121 | * @return Caller |
||
122 | */ |
||
123 | 99 | public function execute($cmd, $git = true, $cwd = null, $acceptedExitCodes = array(0)) |
|
152 | |||
153 | /** |
||
154 | * returns the output of the last executed command |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | 2 | public function getOutput() |
|
162 | |||
163 | /** |
||
164 | * returns the output of the last executed command as an array of lines |
||
165 | * |
||
166 | * @param bool $stripBlankLines remove the blank lines |
||
167 | * |
||
168 | * @return array |
||
169 | */ |
||
170 | 91 | public function getOutputLines($stripBlankLines = false) |
|
185 | |||
186 | /** |
||
187 | * Get RawOutput |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | 1 | public function getRawOutput() |
|
195 | |||
196 | /** |
||
197 | * returns the error output of the last executed command |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | public function getErrorOutput() |
||
205 | |||
206 | /** |
||
207 | * returns the error output of the last executed command as an array of lines |
||
208 | * |
||
209 | * @param bool $stripBlankLines remove the blank lines |
||
210 | * |
||
211 | * @return array |
||
212 | */ |
||
213 | public function getErrorLines($stripBlankLines = false) |
||
228 | |||
229 | /** |
||
230 | * Get RawErrorOutput |
||
231 | * |
||
232 | * @return string |
||
233 | */ |
||
234 | public function getRawErrorOutput() |
||
238 | } |
||
239 |