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 ( a74bc8...6e7b49 )
by Sergey
03:20
created

ObjectMetadata::mergeMetadata()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 8
Ratio 53.33 %

Code Coverage

Tests 5
CRAP Score 4.125

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 15
ccs 5
cts 10
cp 0.5
rs 9.4285
cc 3
eloc 9
nc 3
nop 1
crap 4.125
1
<?php
2
/*
3
 * This file is part of the reva2/jsonapi.
4
 *
5
 * (c) OrbitScripts LLC <[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\ObjectMetadataInterface;
15
use Reva2\JsonApi\Contracts\Decoders\Mapping\PropertyMetadataInterface;
16
17
/**
18
 * ObjectMetadata
19
 *
20
 * @package Reva2\JsonApi\Decoders\Mapping
21
 * @author Sergey Revenko <[email protected]>
22
 */
23
class ObjectMetadata extends ClassMetadata implements ObjectMetadataInterface
24
{
25
    /**
26
     * @var PropertyMetadataInterface[]
27
     */
28
    public $properties = [];
29
30
    /**
31
     * Returns object properties metadata
32
     *
33
     * @return PropertyMetadataInterface[]
34
     */
35 1
    public function getProperties()
36
    {
37 1
        return $this->properties;
38
    }
39
40
    /**
41
     * Adds property metadata
42
     *
43
     * @param PropertyMetadataInterface $metadata
44
     * @return $this
45
     */
46 1
    public function addProperty(PropertyMetadataInterface $metadata)
47
    {
48 1
        $this->properties[$metadata->getPropertyName()] = $metadata;
49
50 1
        return $this;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56 1
    public function mergeMetadata(ObjectMetadataInterface $metadata = null)
57
    {
58 1 View Code Duplication
        if (null === $metadata) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
            return $this;
60 1
        } elseif (!$metadata instanceof ObjectMetadataInterface) {
61
            throw new \InvalidArgumentException(sprintf(
62
                "Couldn't merge metadata from %s instance",
63
                get_class($metadata)
64
            ));
65
        }
66
67 1
        $this->properties = array_merge($this->properties, $metadata->getProperties());
68
69 1
        return $this;
70
    }
71
}