Conditions | 3 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
33 | public function run($jobId, array $parameters = []) |
||
34 | { |
||
35 | $method = (empty($parameters)) ? 'GET' : 'POST'; |
||
36 | |||
37 | $options = [ |
||
38 | 'http' => [ |
||
39 | 'header' => "X-Rundeck-Auth-Token: {$this->config['token']}\r\n", |
||
40 | 'method' => $method, |
||
41 | ], |
||
42 | ]; |
||
43 | |||
44 | if ($method == 'POST') { |
||
45 | $options['http']['header'] .= "Content-type: application/x-www-form-urlencoded\r\n"; |
||
46 | $options['http']['content'] = http_build_query($parameters); |
||
47 | } |
||
48 | |||
49 | $context = stream_context_create($options); |
||
50 | |||
51 | return file_get_contents($this->getApiUrl($jobId), false, $context); |
||
52 | } |
||
53 | |||
77 |