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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 30
ccs 0
cts 18
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B create() 0 23 5
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