Completed
Pull Request — master (#119)
by Toby
03:12
created

LinksTrait::setLinks()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
trait LinksTrait
15
{
16
    private $links = [];
17
18
    /**
19
     * Set the links.
20
     *
21
     * @param array $links
22
     */
23
    public function setLinks(array $links)
24
    {
25
        $this->links = $links;
26
    }
27
28
    /**
29
     * Set a link.
30
     *
31
     * @param string $key
32
     * @param string|Link $value
33
     */
34 9
    public function setLink($key, $value)
35
    {
36 9
        $this->links[$key] = $value;
37 9
    }
38
39
    /**
40
     * Remove a link.
41
     *
42
     * @param string $key
43
     */
44 3
    public function removeLink($key)
45
    {
46 3
        unset($this->links[$key]);
47 3
    }
48
}
49