Completed
Pull Request — master (#119)
by Toby
65:37 queued 63:37
created

LinksTrait::addPaginationLink()   C

Complexity

Conditions 8
Paths 16

Size

Total Lines 30
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 8

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 21
cts 21
cp 1
rs 5.3846
c 0
b 0
f 0
cc 8
eloc 16
nc 16
nop 5
crap 8
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
trait LinksTrait
15
{
16
    /**
17
     * The links.
18
     *
19
     * @var array
20
     */
21
    protected $links = [];
22
23
    /**
24
     * Get the links.
25
     *
26
     * @return array
27
     */
28 3
    public function getLinks()
29
    {
30 3
        return $this->links;
31
    }
32
33
    /**
34
     * Replace the links.
35
     *
36
     * @param array $links
37
     */
38
    public function replaceLinks(array $links)
39
    {
40
        $this->links = $links;
41
    }
42
43
    /**
44
     * Set a link.
45
     *
46
     * @param string $key
47
     * @param string|Link $value
48
     */
49 6
    public function setLink($key, $value)
50
    {
51 6
        $this->links[$key] = $value;
52 6
    }
53
54
    /**
55
     * Remove a link.
56
     *
57
     * @param string $key
58
     */
59 3
    public function removeLink($key)
60
    {
61 3
        unset($this->links[$key]);
62 3
    }
63
}
64