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() |
|
|
|
|
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() |
|
|
|
|
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() |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
return $this->shortDescription; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
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.