Completed
Push — v2 ( 507181...9b4b78 )
by Beñat
02:57
created

Privilege::fromJson()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.2
cc 4
eloc 7
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * Copyright (c) 2014-2016 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
namespace BenatEspina\StackExchangeApiClient\Model;
13
14
/**
15
 * The privilege model class.
16
 *
17
 * @author Beñat Espiña <[email protected]>
18
 */
19
class Privilege implements Model
20
{
21
    protected $description;
22
    protected $reputation;
23
    protected $shortDescription;
24
25
    public static function fromJson(array $data)
26
    {
27
        $instance = new self();
28
        $instance
29
            ->setDescription(array_key_exists('description', $data) ? $data['description'] : null)
30
            ->setReputation(array_key_exists('reputation', $data) ? $data['reputation'] : null)
31
            ->setShortDescription(array_key_exists('short_description', $data) ? $data['short_description'] : null);
32
33
        return $instance;
34
    }
35
36
    public static function fromProperties($description, $reputation, $shortDescription)
37
    {
38
        $instance = new self();
39
        $instance
40
            ->setDescription($description)
41
            ->setReputation($reputation)
42
            ->setShortDescription($shortDescription);
43
44
        return $instance;
45
    }
46
47
    public function setDescription($description)
48
    {
49
        $this->description = $description;
50
51
        return $this;
52
    }
53
54
    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...
55
    {
56
        return $this->description;
57
    }
58
59
    public function setReputation($reputation)
60
    {
61
        $this->reputation = $reputation;
62
63
        return $this;
64
    }
65
66
    public function getReputation()
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...
67
    {
68
        return $this->reputation;
69
    }
70
71
    public function setShortDescription($shortDescription)
72
    {
73
        $this->shortDescription = $shortDescription;
74
75
        return $this;
76
    }
77
78
    public function getShortDescription()
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...
79
    {
80
        return $this->shortDescription;
81
    }
82
}
83