1 | <?php |
||
32 | class Caller implements CallerInterface |
||
33 | { |
||
34 | /** |
||
35 | * GitBinary instance |
||
36 | * |
||
37 | * @var \GitElephant\GitBinary |
||
38 | */ |
||
39 | private $binary; |
||
40 | |||
41 | /** |
||
42 | * the repository path |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | private $repositoryPath; |
||
47 | |||
48 | /** |
||
49 | * the output lines of the command |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | private $outputLines = array(); |
||
54 | |||
55 | /** |
||
56 | * raw output |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | private $rawOutput; |
||
61 | |||
62 | /** |
||
63 | * Callback for real-time output yielding |
||
64 | * |
||
65 | * @var callable |
||
66 | */ |
||
67 | 103 | private $callback; |
|
68 | |||
69 | 103 | /** |
|
70 | * Class constructor |
||
71 | 103 | * |
|
72 | 1 | * @param \GitElephant\GitBinary $binary the binary |
|
73 | * @param string $repositoryPath the physical base path for the repository |
||
74 | */ |
||
75 | 103 | public function __construct(GitBinary $binary, $repositoryPath) |
|
85 | 1 | ||
86 | /** |
||
87 | * Get the binary path |
||
88 | * |
||
89 | * @return mixed |
||
90 | */ |
||
91 | public function getBinaryPath() |
||
95 | |||
96 | /** |
||
97 | * Executes a command |
||
98 | * |
||
99 | * @param string $cmd the command to execute |
||
100 | * @param bool $git if the command is git or a generic command |
||
101 | * @param null $cwd the directory where the command must be executed |
||
102 | * @param array $acceptedExitCodes exit codes accepted to consider the command execution successful |
||
103 | 97 | * |
|
104 | * @throws \RuntimeException |
||
105 | 97 | * @throws \Symfony\Component\Process\Exception\InvalidArgumentException |
|
106 | 97 | * @throws \Symfony\Component\Process\Exception\ProcessTimedOutException |
|
107 | 97 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
|
108 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
109 | 97 | * @return Caller |
|
110 | 97 | */ |
|
111 | 97 | public function execute($cmd, $git = true, $cwd = null, $acceptedExitCodes = array(0)) |
|
145 | |||
146 | 89 | /** |
|
147 | 80 | * returns the raw output of the last executed command |
|
148 | 80 | * |
|
149 | 80 | * @return string |
|
150 | 80 | */ |
|
151 | 80 | public function getOutput() |
|
155 | |||
156 | /** |
||
157 | 43 | * returns the output of the last executed command as an array of lines |
|
158 | * |
||
159 | * @param bool $stripBlankLines remove the blank lines |
||
160 | * |
||
161 | * @return array |
||
162 | */ |
||
163 | public function getOutputLines($stripBlankLines = false) |
||
178 | |||
179 | /** |
||
180 | * Get RawOutput |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | public function getRawOutput() |
||
188 | |||
189 | /** |
||
190 | * @param callable $callback |
||
191 | * @return $this |
||
192 | */ |
||
193 | public function setExecuteCallback(callable $callback){ |
||
197 | } |
||
198 |