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.
Completed
Push — master ( c22db0...fa2159 )
by Sergey
03:18
created

ResourceMetadata   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A setName() 0 6 1
A getAttributes() 0 4 1
A addAttribute() 0 6 1
A getRelationships() 0 4 1
A addRelationship() 0 6 1
B mergeMetadata() 0 22 4
1
<?php
2
/*
3
 * This file is part of the reva2/jsonapi.
4
 *
5
 * (c) Sergey Revenko <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
12
namespace Reva2\JsonApi\Decoders\Mapping;
13
14
use Reva2\JsonApi\Contracts\Decoders\Mapping\PropertyMetadataInterface;
15
use Reva2\JsonApi\Contracts\Decoders\Mapping\ResourceMetadataInterface;
16
17
/**
18
 * JSON API resource metadata
19
 *
20
 * @package Reva2\JsonApi\Decoders\Mapping
21
 * @author Sergey Revenko <[email protected]>
22
 */
23
class ResourceMetadata extends ClassMetadata implements ResourceMetadataInterface
24
{
25
    /**
26
     * @var string
27
     * @internal
28
     */
29
    public $name;
30
31
    /**
32
     * @var PropertyMetadataInterface[]
33
     * @internal
34
     */
35
    public $attributes = [];
36
37
    /**
38
     * @var PropertyMetadataInterface[]
39
     * @internal
40
     */
41
    public $relationships = [];
42
43
    /**
44
     * @inheritdoc
45
     */
46 1
    public function getName()
47
    {
48 1
        return $this->name;
49
    }
50
51
    /**
52
     * @param string $name
53
     * @return $this
54
     */
55 3
    public function setName($name = null)
56
    {
57 3
        $this->name = $name;
58
59 3
        return $this;
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65 2
    public function getAttributes()
66
    {
67 2
        return $this->attributes;
68
    }
69
70
    /**
71
     * Add resource attribute metadata
72
     *
73
     * @param PropertyMetadataInterface $attribute
74
     * @return $this
75
     */
76 3
    public function addAttribute(PropertyMetadataInterface $attribute)
77
    {
78 3
        $this->attributes[$attribute->getPropertyName()] = $attribute;
79
80 3
        return $this;
81
    }
82
83
    /**
84
     * @inheritdoc
85
     */
86 2
    public function getRelationships()
87
    {
88 2
        return $this->relationships;
89
    }
90
91
    /**
92
     * Add resource relationship metadata
93
     *
94
     * @param PropertyMetadataInterface $relationship
95
     * @return $this
96
     */
97 3
    public function addRelationship(PropertyMetadataInterface $relationship)
98
    {
99 3
        $this->relationships[$relationship->getPropertyName()] = $relationship;
100
101 3
        return $this;
102
    }
103
104
    /**
105
     * @inheritdoc
106
     */
107 2
    public function mergeMetadata($metadata = null)
108
    {
109 2
        if (null !== $metadata) {
110 2
            if (!$metadata instanceof ResourceMetadataInterface) {
111
                /* @var $metadata \Reva2\JsonApi\Contracts\Decoders\Mapping\GenericMetadataInterface */
112
113 1
                throw new \RuntimeException(sprintf(
114 1
                    "Failed to merge metadata from parent class %s",
115 1
                    $metadata->getClassName()
116 1
                ));
117
            }
118
119 1
            if (empty($this->name)) {
120 1
                $this->name = $metadata->getName();
121 1
            }
122
123 1
            $this->attributes = array_merge($this->attributes, $metadata->getAttributes());
124 1
            $this->relationships = array_merge($this->relationships, $metadata->getRelationships());
125 1
        }
126
127 1
        return $this;
128
    }
129
}