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

LinksTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 50
ccs 8
cts 11
cp 0.7272
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getLinks() 0 4 1
A replaceLinks() 0 4 1
A setLink() 0 4 1
A removeLink() 0 4 1
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