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\Infrastructure\Domain\Model; |
13
|
|
|
|
14
|
|
|
use BenatEspina\StackExchangeApiClient\Domain\Model\BadgeCount; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* The anemic implementation of badge count domain class. |
18
|
|
|
* |
19
|
|
|
* @author Beñat Espiña <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class AnemicBadgeCount implements BadgeCount |
22
|
|
|
{ |
23
|
|
|
private $bronze; |
24
|
|
|
private $gold; |
25
|
|
|
private $silver; |
26
|
|
|
|
27
|
|
|
public static function fromJson($data) |
28
|
|
|
{ |
29
|
|
|
return new self( |
30
|
|
|
array_key_exists('bronze', $data) ? $data['bronze'] : null, |
31
|
|
|
array_key_exists('gold', $data) ? $data['gold'] : null, |
32
|
|
|
array_key_exists('silver', $data) ? $data['silver'] : null |
33
|
|
|
); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public static function fromProperties($bronze, $gold, $silver) |
37
|
|
|
{ |
38
|
|
|
return new self($bronze, $gold, $silver); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
private function __construct($bronze = null, $gold = null, $silver = null) |
42
|
|
|
{ |
43
|
|
|
$this->bronze = $bronze; |
44
|
|
|
$this->gold = $gold; |
45
|
|
|
$this->silver = $silver; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getBronze() |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
return $this->bronze; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function setBronze($bronze) |
54
|
|
|
{ |
55
|
|
|
$this->bronze = $bronze; |
56
|
|
|
|
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getGold() |
|
|
|
|
61
|
|
|
{ |
62
|
|
|
return $this->gold; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function setGold($gold) |
66
|
|
|
{ |
67
|
|
|
$this->gold = $gold; |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getSilver() |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
return $this->silver; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function setSilver($silver) |
78
|
|
|
{ |
79
|
|
|
$this->silver = $silver; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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.