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

Link::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 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