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.

RelationFactory::getRelations()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
rs 9.2
cc 4
eloc 8
nc 4
nop 1
1
<?php
2
3
namespace Halapi\Factory;
4
5
use Halapi\Relation\RelationInterface;
6
7
/**
8
 * Class RelationFactory.
9
 *
10
 * @author Romain Richard
11
 */
12
class RelationFactory
13
{
14
    /**
15
     * @var array
16
     */
17
    private $relations;
18
19
    /**
20
     * RelationFactory constructor.
21
     *
22
     * @param array $relations
23
     */
24
    public function __construct(array $relations)
25
    {
26
        $this->relations = $relations;
27
    }
28
29
    /**
30
     * Get the relations of an Entity.
31
     * Relations processors are passed to the constructor.
32
     *
33
     * @param object $resource
34
     *
35
     * @return array
36
     */
37
    public function getRelations($resource)
38
    {
39
        $resourceRelations = [];
40
41
        foreach ($this->relations as $relation) {
42
            if ($relation instanceof RelationInterface) {
43
                $relationContent = $relation->getRelation($resource);
44
45
                if ($relationContent) {
46
                    $resourceRelations[$relation->getName()] = $relationContent;
47
                }
48
            }
49
        }
50
51
        return $resourceRelations;
52
    }
53
}
54