GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SystemsResponseFactory::create()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
ccs 0
cts 18
cp 0
rs 8.5906
cc 5
eloc 12
nc 5
nop 1
crap 30
1
<?php
2
3
namespace JumpCloud\Factory;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use GuzzleHttp\Psr7\Response;
7
use JumpCloud\Model\System;
8
use JumpCloud\Response\SystemsResponse;
9
use Webmozart\Json\JsonDecoder;
10
11
/**
12
 * Class SystemsResponseFactory
13
 * @package JumpCloud\Factory
14
 */
15
class SystemsResponseFactory implements ResponseFactoryInterface
16
{
17
    /**
18
     * @param Response $response
19
     * @return SystemsResponse
20
     */
21
    public function create(Response $response)
22
    {
23
        $jsonDecoder = new JsonDecoder();
24
        $collection = new ArrayCollection();
25
26
        if ($response->getStatusCode() === 200) {
27
            $data = (string)$response->getBody();
28
29
            try {
30
                $data = $jsonDecoder->decode($data);
31
            } catch (\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
32
33
            }
34
35
            if (isset($data->results)) {
36
                foreach ($data->results as $result) {
37
                    $collection->add(System::createFromApi($result));
38
                }
39
            }
40
        }
41
42
        return new SystemsResponse($response, $collection);
43
    }
44
}
45