Error::fromProperties()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * (c) Beñat Espiña <[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
declare(strict_types=1);
13
/*
14
 * This file is part of the Stack Exchange Api Client library.
15
 *
16
 * (c) Beñat Espiña <[email protected]>
17
 *
18
 * For the full copyright and license information, please view the LICENSE
19
 * file that was distributed with this source code.
20
 */
21
22
namespace BenatEspina\StackExchangeApiClient\Model;
23
24
/**
25
 * Class error model class.
26
 *
27
 * @author Beñat Espiña <[email protected]>
28
 */
29
class Error implements Model
30
{
31
    protected $id;
32
    protected $name;
33
    protected $description;
34
35
    public static function fromJson(array $data)
36
    {
37
        $instance = new self();
38
        $instance
39
            ->setId(array_key_exists('error_id', $data) ? $data['error_id'] : null)
40
            ->setName(array_key_exists('error_name', $data) ? $data['error_name'] : null)
41
            ->setDescription(array_key_exists('description', $data) ? $data['description'] : null);
42
43
        return $instance;
44
    }
45
46
    public static function fromProperties($id, $name, $description)
47
    {
48
        $instance = new self();
49
        $instance
50
            ->setId($id)
51
            ->setName($name)
52
            ->setDescription($description);
53
54
        return $instance;
55
    }
56
57
    public function getId()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
58
    {
59
        return $this->id;
60
    }
61
62
    public function setId($id)
63
    {
64
        $this->id = $id;
65
66
        return $this;
67
    }
68
69
    public function getName()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
70
    {
71
        return $this->name;
72
    }
73
74
    public function setName($name)
75
    {
76
        $this->name = $name;
77
78
        return $this;
79
    }
80
81
    public function getDescription()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
82
    {
83
        return $this->description;
84
    }
85
86
    public function setDescription($description)
87
    {
88
        $this->description = $description;
89
90
        return $this;
91
    }
92
}
93