Completed
Pull Request — master (#119)
by Toby
02:45
created

Link   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 22
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setHref() 0 4 1
A jsonSerialize() 0 4 2
1
<?php
2
3
/*
4
 * This file is part of JSON-API.
5
 *
6
 * (c) Toby Zerner <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tobscure\JsonApi;
13
14
use JsonSerializable;
15
16
class Link implements JsonSerializable
17
{
18
    use MetaTrait;
19
20
    protected $href;
21
22
    public function __construct($href, $meta = null)
23
    {
24
        $this->href = $href;
25
        $this->meta = $meta;
26
    }
27
28
    public function setHref($href)
29
    {
30
        $this->href = $href;
31
    }
32
33
    public function jsonSerialize()
34
    {
35
        return $this->meta ? ['href' => $this->href, 'meta' => $this->meta] : $this->href;
36
    }
37
}
38