Code Duplication    Length = 89-107 lines in 2 locations

src/Model/BadgeCount.php 1 location

@@ 22-110 (lines=89) @@
19
 *
20
 * @author Beñat Espiña <[email protected]>
21
 */
22
class BadgeCount implements BadgeCountInterface
23
{
24
    /**
25
     * Number of bronze badges.
26
     *
27
     * @var int
28
     */
29
    protected $bronze;
30
31
    /**
32
     * Number of gold badges.
33
     *
34
     * @var int
35
     */
36
    protected $gold;
37
38
    /**
39
     * Number of silver badges.
40
     *
41
     * @var int
42
     */
43
    protected $silver;
44
45
    /**
46
     * Constructor.
47
     *
48
     * @param null|mixed[] $json The json string being decoded
49
     */
50
    public function __construct($json = null)
51
    {
52
        $this->bronze = Util::setIfIntegerExists($json, 'bronze');
53
        $this->gold = Util::setIfIntegerExists($json, 'gold');
54
        $this->silver = Util::setIfIntegerExists($json, 'silver');
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60
    public function setBronze($bronze)
61
    {
62
        $this->bronze = $bronze;
63
64
        return $this;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function getBronze()
71
    {
72
        return $this->bronze;
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function setGold($gold)
79
    {
80
        $this->gold = $gold;
81
82
        return $this;
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function getGold()
89
    {
90
        return $this->gold;
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function setSilver($silver)
97
    {
98
        $this->silver = $silver;
99
100
        return $this;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106
    public function getSilver()
107
    {
108
        return $this->silver;
109
    }
110
}
111

src/Model/Traits/CountTrait.php 1 location

@@ 23-129 (lines=107) @@
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 */
23
trait CountTrait
24
{
25
    /**
26
     * Answer count.
27
     *
28
     * @var int
29
     */
30
    protected $answerCount;
31
32
    /**
33
     * The total Badges, segregated by rank.
34
     *
35
     * @var \BenatEspina\StackExchangeApiClient\Model\Interfaces\BadgeCountInterface
36
     */
37
    protected $badgeCount;
38
39
    /**
40
     * Number of questions.
41
     *
42
     * @var int
43
     */
44
    protected $questionCount;
45
46
    /**
47
     * Sets number of answers.
48
     *
49
     * @param int $answerCount The number of answers
50
     *
51
     * @return $this self Object
52
     */
53
    public function setAnswerCount($answerCount)
54
    {
55
        $this->answerCount = $answerCount;
56
57
        return $this;
58
    }
59
60
    /**
61
     * Gets number of answers.
62
     *
63
     * @return int
64
     */
65
    public function getAnswerCount()
66
    {
67
        return $this->answerCount;
68
    }
69
70
    /**
71
     * Sets badge count.
72
     *
73
     * @param \BenatEspina\StackExchangeApiClient\Model\Interfaces\BadgeCountInterface $badgeCount The badge count
74
     *
75
     * @return $this self Object
76
     */
77
    public function setBadgeCount(BadgeCountInterface $badgeCount)
78
    {
79
        $this->badgeCount = $badgeCount;
80
81
        return $this;
82
    }
83
84
    /**
85
     * Gets badge count.
86
     *
87
     * @return \BenatEspina\StackExchangeApiClient\Model\Interfaces\BadgeCountInterface
88
     */
89
    public function getBadgeCount()
90
    {
91
        return $this->badgeCount;
92
    }
93
94
    /**
95
     * Sets question id.
96
     *
97
     * @param int $questionCount The question id
98
     *
99
     * @return $this self Object
100
     */
101
    public function setQuestionCount($questionCount)
102
    {
103
        $this->questionCount = $questionCount;
104
105
        return $this;
106
    }
107
108
    /**
109
     * Gets question id.
110
     *
111
     * @return int
112
     */
113
    public function getQuestionCount()
114
    {
115
        return $this->questionCount;
116
    }
117
118
    /**
119
     * Loads the variables if the data exist into resource. It works like a constructor.
120
     *
121
     * @param null|mixed[] $resource The resource
122
     */
123
    protected function loadCount($resource)
124
    {
125
        $this->answerCount = Util::setIfIntegerExists($resource, 'answer_count');
126
        $this->badgeCount = new BadgeCount(Util::setIfArrayExists($resource, 'badge_counts'));
127
        $this->questionCount = Util::setIfIntegerExists($resource, 'question_count');
128
    }
129
}
130