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.

LinksFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 49
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 13 3
A __construct() 0 6 1
1
<?php
2
3
namespace Hateoas\Factory;
4
5
use Hateoas\Configuration\RelationsRepository;
6
use Hateoas\Model\Link;
7
use Hateoas\Serializer\ExclusionManager;
8
use JMS\Serializer\SerializationContext;
9
10
/**
11
 * @author Adrien Brault <[email protected]>
12
 */
13
class LinksFactory
14
{
15
    /**
16
     * @var RelationsRepository
17
     */
18
    private $relationsRepository;
19
20
    /**
21
     * @var LinkFactory
22
     */
23
    private $linkFactory;
24
25
    /**
26
     * @var ExclusionManager
27
     */
28
    private $exclusionManager;
29
30
    /**
31
     * @param RelationsRepository $relationsRepository
32
     * @param LinkFactory         $linkFactory
33
     * @param ExclusionManager    $exclusionManager
34
     */
35
    public function __construct(RelationsRepository $relationsRepository, LinkFactory $linkFactory, ExclusionManager $exclusionManager)
36
    {
37
        $this->relationsRepository = $relationsRepository;
38
        $this->linkFactory         = $linkFactory;
39
        $this->exclusionManager    = $exclusionManager;
40
    }
41
42
    /**
43
     * @param object               $object
44
     * @param SerializationContext $context
45
     *
46
     * @return Link[]
47
     */
48
    public function create($object, SerializationContext $context)
49
    {
50
        $links = array();
51
        foreach ($this->relationsRepository->getRelations($object) as $relation) {
52
            if ($this->exclusionManager->shouldSkipLink($object, $relation, $context)) {
53
                continue;
54
            }
55
56
            $links[] = $this->linkFactory->createLink($object, $relation);
57
        }
58
59
        return $links;
60
    }
61
}
62