| Conditions | 5 |
| Paths | 5 |
| Total Lines | 33 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 5.0031 |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | 3 | public function execute($resource = null) |
|
| 21 | { |
||
| 22 | 3 | if (null === $resource) { |
|
| 23 | 1 | throw new QueryErrorException('Could not delete no resource'); |
|
| 24 | } |
||
| 25 | |||
| 26 | 2 | $this->populateCDNResources(); |
|
| 27 | |||
| 28 | 2 | $cdnResources = array_filter($this->cdnResources, function($value, $key) use ($resource) { |
|
|
|
|||
| 29 | 2 | return $value['cname'] == $resource; |
|
| 30 | 2 | }, ARRAY_FILTER_USE_BOTH); |
|
| 31 | |||
| 32 | 2 | if (count($cdnResources) > 1) { |
|
| 33 | 1 | throw new QueryErrorException('Could not delete more than one resource'); |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | foreach ($cdnResources as $cdnResource) { |
|
| 37 | 1 | $response = $this->client->post($this->url, [ |
|
| 38 | 'form_params' => [ |
||
| 39 | 1 | 'id' => $cdnResource['id'], |
|
| 40 | 1 | 'login' => $this->login, |
|
| 41 | 1 | 'passwd' => $this->password, |
|
| 42 | ] |
||
| 43 | 1 | ]); |
|
| 44 | 1 | $data = json_decode($response->getBody()->getContents(), true); |
|
| 45 | |||
| 46 | 1 | if ('ok' !== $data['status']) { |
|
| 47 | throw new QueryErrorException(json_encode($data)); |
||
| 48 | } |
||
| 49 | 1 | } |
|
| 50 | |||
| 51 | 1 | return; |
|
| 52 | } |
||
| 53 | } |
||
| 54 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.