LinkObject   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 42
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getReference() 0 4 1
A __toString() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Document;
5
6
use Mikemirten\Component\JsonApi\Document\Behaviour\MetadataAwareInterface;
7
use Mikemirten\Component\JsonApi\Document\Behaviour\MetadataContainer;
8
9
/**
10
 * Link Object
11
 *
12
 * @see http://jsonapi.org/format/#document-links
13
 *
14
 * @package Mikemirten\Component\JsonApi\Document
15
 */
16
class LinkObject implements MetadataAwareInterface
17
{
18
    use MetadataContainer;
19
20
    /**
21
     * Link's reference
22
     *
23
     * @var string
24
     */
25
    protected $reference;
26
27
    /**
28
     * LinkObject constructor.
29
     *
30
     * @param string $reference
31
     */
32 9
    public function __construct(string $reference, array $metadata = [])
33
    {
34 9
        $this->reference = $reference;
35 9
        $this->metadata  = $metadata;
36 9
    }
37
38
    /**
39
     * Get reference
40
     *
41
     * @return string
42
     */
43 3
    public function getReference(): string
44
    {
45 3
        return $this->reference;
46
    }
47
48
    /**
49
     * Cast to a string
50
     *
51
     * @return string
52
     */
53 3
    public function __toString(): string
54
    {
55 3
        return sprintf('Link referenced to "%s"', $this->reference);
56
    }
57
}