Link   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 36
ccs 13
cts 13
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getHref() 0 3 1
A toArray() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Swis\JsonApi\Client;
6
7
use Swis\JsonApi\Client\Concerns\HasMeta;
8
9
class Link
10
{
11
    use HasMeta;
12
13
    /**
14
     * @var string
15
     */
16
    protected $href;
17
18 148
    public function __construct(string $href, ?Meta $meta = null)
19
    {
20 148
        $this->href = $href;
21 148
        $this->meta = $meta;
22 74
    }
23
24 44
    public function getHref(): string
25
    {
26 44
        return $this->href;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     *
32
     * @return array
33
     */
34 40
    public function toArray()
35
    {
36 40
        $array = [
37 40
            'href' => $this->getHref(),
38 20
        ];
39
40 40
        if ($this->getMeta() !== null) {
41 12
            $array['meta'] = $this->getMeta()->toArray();
42
        }
43
44 40
        return $array;
45
    }
46
}
47