Passed
Push — master ( fc3e4b...e9bd9f )
by Michael
02:26
created

IdentifierCollectionDocument   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 26
loc 26
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A toArray() 8 8 1

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
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Document;
5
6
use Mikemirten\Component\JsonApi\Document\Behaviour\IdentifierCollectionAwareInterface;
7
use Mikemirten\Component\JsonApi\Document\Behaviour\IdentifierCollectionContainer;
8
9
/**
10
 * Identifier Collection Document
11
 *
12
 * @see http://jsonapi.org/format/#document-structure
13
 *
14
 * @package Mikemirten\Component\JsonApi\Document
15
 */
16 View Code Duplication
class IdentifierCollectionDocument extends AbstractDocument implements IdentifierCollectionAwareInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
17
{
18
    use IdentifierCollectionContainer;
19
20
    /**
21
     * IdentifierCollectionDocument constructor.
22
     *
23
     * @param array $metadata
24
     */
25 7
    public function __construct(array $metadata = [])
26
    {
27 7
        $this->metadata = $metadata;
28 7
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 3
    public function toArray(): array
34
    {
35 3
        $data = parent::toArray();
36
37 3
        $data['data'] = $this->identifiersToArray();
38
39 3
        return $data;
40
    }
41
}