Completed
Pull Request — master (#119)
by Toby
65:35
created

Link   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getHref() 0 4 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 getHref()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
29
    {
30
        return $this->href;
31
    }
32
33
    public function setHref($href)
34
    {
35
        $this->href = $href;
36
    }
37
38
    public function jsonSerialize()
39
    {
40
        return $this->meta ? ['href' => $this->href, 'meta' => $this->meta] : $this->href;
41
    }
42
}
43