Conditions | 6 |
Paths | 10 |
Total Lines | 29 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function doValidation(ResponseInterface $response) |
||
19 | { |
||
20 | |||
21 | if ($response instanceof ResourcesAwareResponse) { |
||
22 | $resources = $response->getResources(); |
||
23 | |||
24 | $errorList = []; |
||
25 | |||
26 | foreach ($resources as $resource) { |
||
27 | if ($resource['http_status'] >= 400) { |
||
28 | $errorList[] = $resource; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | if (count($errorList) > 0) { |
||
33 | $count = count($errorList); |
||
34 | $msg = 'Found ' . $count . ' resources with status code 4xx or 5xx. <ul>'; |
||
35 | foreach ($errorList as $error) { |
||
36 | $msg .= '<li>' . $error['name'] . ' (' . $error['http_status'] . ')</li>'; |
||
37 | } |
||
38 | $msg .= '</ul>'; |
||
39 | return new CheckResult(CheckResult::STATUS_FAILURE, $msg, $count); |
||
40 | } else { |
||
41 | return new CheckResult(CheckResult::STATUS_SUCCESS, 'No resources with status 4xx or 5xx found.', 0); |
||
42 | } |
||
43 | } else { |
||
44 | return new CheckResult(CheckResult::STATUS_SKIPPED, 'Expected ResourcesAwareResponse. Skipped.'); |
||
45 | } |
||
46 | } |
||
47 | } |
||
48 |