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

Error::setAboutLink()   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
use JsonSerializable;
15
16
class Error implements JsonSerializable
17
{
18
    use LinksTrait, MetaTrait;
19
20
    private $id;
21
    private $status;
22
    private $code;
23
    private $title;
24
    private $detail;
25
    private $source;
26
27
    public function setId($id)
28
    {
29
        $this->id = $id;
30
    }
31
32
    public function setAboutLink($link)
33
    {
34
        $this->links['about'] = $link;
35
    }
36
37
    public function setStatus($status)
38
    {
39
        $this->status = $status;
40
    }
41
42
    public function setCode($code)
43
    {
44
        $this->code = $code;
45
    }
46
47
    public function setTitle($title)
48
    {
49
        $this->title = $title;
50
    }
51
52
    public function setDetail($detail)
53
    {
54
        $this->detail = $detail;
55
    }
56
57
    public function setSourcePointer($pointer)
58
    {
59
        $this->source['pointer'] = $pointer;
60
    }
61
62
    public function setSourceParameter($parameter)
63
    {
64
        $this->source['parameter'] = $parameter;
65
    }
66
67
    public function jsonSerialize()
68
    {
69
        return array_filter(
70
            [
71
                'id' => $this->id,
72
                'links' => $this->links,
73
                'status' => $this->status,
74
                'code' => $this->code,
75
                'title' => $this->title,
76
                'detail' => $this->detail,
77
                'source' => $this->source,
78
                'meta' => $this->meta
79
            ]
80
        );
81
    }
82
}
83