Completed
Push — master ( a95c92...e40b6a )
by Beñat
04:36
created

CountTrait::setBadgeCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 6
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Stack Exchange Api Client library.
5
 *
6
 * Copyright (c) 2015 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\Traits;
13
14
use BenatEspina\StackExchangeApiClient\Model\BadgeCount;
15
use BenatEspina\StackExchangeApiClient\Model\Interfaces\BadgeCountInterface;
16
use BenatEspina\StackExchangeApiClient\Util\Util;
17
18
/**
19
 * Trait CountTrait.
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 */
23 View Code Duplication
trait CountTrait
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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