Passed
Push — master ( c5502b...385fa8 )
by Radu
04:32
created

Error::setStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace WebServCo\Api\JsonApi;
3
4
final class Error
5
{
6
    protected $id;
7
    protected $links;
8
    protected $status;
9
    protected $code;
10
    protected $title;
11
    protected $detail;
12
    protected $source;
13
    protected $meta;
14
15
    public function __construct()
16
    {
17
        $this->meta = [];
18
    }
19
20
    public function setStatus($status)
21
    {
22
        $this->status = $status;
23
    }
24
25
    public function setTitle($title)
26
    {
27
        $this->title = $title;
28
    }
29
30
    public function setDetail($detail)
31
    {
32
        $this->detail = $detail;
33
    }
34
35
    public function setMeta($key, $value)
36
    {
37
        $this->meta[$key] = $value;
38
    }
39
40
    public function toArray()
41
    {
42
        $array = [];
43
        foreach (get_object_vars($this) as $key => $value) {
44
            if (!empty($value)) {
45
                $array[$key] = $value;
46
            }
47
        }
48
        return $array;
49
    }
50
}
51