IdentifierCollectionRelationship::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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 Relationship
11
 *
12
 * @see http://jsonapi.org/format/#document-resource-object-relationships
13
 *
14
 * @package Mikemirten\Component\JsonApi\Document
15
 */
16 View Code Duplication
class IdentifierCollectionRelationship extends AbstractRelationship 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
     * IdentifierCollectionRelationship constructor.
22
     *
23
     * @param array $metadata
24
     */
25 21
    public function __construct(array $metadata = [])
26
    {
27 21
        $this->metadata = $metadata;
28 21
    }
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
42
    /**
43
     * Cast to a string
44
     *
45
     * @return string
46
     */
47 7
    public function __toString(): string
48
    {
49 7
        return 'Relationship contains a collection of resource-identifiers';
50
    }
51
}