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

Error   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 8

6 Methods

Rating   Name   Duplication   Size   Complexity  
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 __construct() 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 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