Completed
Push — master ( b98498...ed897d )
by Radu
04:47
created

Error   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setTitle() 0 3 1
A setDetail() 0 3 1
A toArray() 0 9 3
A setStatus() 0 3 1
A setMeta() 0 3 1
A getStatus() 0 3 1
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 getStatus()
21
    {
22
        return $this->status;
23
    }
24
25
    public function setStatus($status)
26
    {
27
        $this->status = $status;
28
    }
29
30
    public function setTitle($title)
31
    {
32
        $this->title = $title;
33
    }
34
35
    public function setDetail($detail)
36
    {
37
        $this->detail = $detail;
38
    }
39
40
    public function setMeta($key, $value)
41
    {
42
        $this->meta[$key] = $value;
43
    }
44
45
    public function toArray()
46
    {
47
        $array = [];
48
        foreach (get_object_vars($this) as $key => $value) {
49
            if (!empty($value)) {
50
                $array[$key] = $value;
51
            }
52
        }
53
        return $array;
54
    }
55
}
56