Conditions | 7 |
Paths | 13 |
Total Lines | 33 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
23 | public function run() |
||
24 | { |
||
25 | // This check requires a repository slug to be provided |
||
26 | $slug = $this->getSuite()->getRepositorySlug(); |
||
27 | if (!$slug) { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | try { |
||
32 | $result = $this->getRequestClient() |
||
33 | ->get('https://scrutinizer-ci.com/api/repositories/g/' . $slug) |
||
34 | ->getBody(); |
||
35 | } catch (Exception $ex) { |
||
36 | if ($logger = $this->getSuite()->getLogger()) { |
||
37 | $logger->debug($ex->getMessage()); |
||
38 | } |
||
39 | $result = ''; |
||
40 | } |
||
41 | $response = json_decode($result, true); |
||
42 | |||
43 | // Fetch failure |
||
44 | if (!$response) { |
||
45 | return; |
||
46 | } |
||
47 | |||
48 | // Not set up (404) |
||
49 | if (!isset($response['applications']['master']['index']['_embedded']['project']['metric_values'])) { |
||
50 | return; |
||
51 | } |
||
52 | |||
53 | $metrics = $response['applications']['master']['index']['_embedded']['project']['metric_values']; |
||
54 | if ($metrics['scrutinizer.quality'] >= self::THRESHOLD) { |
||
55 | $this->setSuccessful(true); |
||
56 | } |
||
59 |