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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 16.33 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 8
loc 49
ccs 10
cts 15
cp 0.6667
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getProperties() 0 4 1
A addProperty() 0 6 1
A mergeMetadata() 8 15 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}