Completed
Pull Request — master (#58)
by Alexis
02:59
created

User   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 217
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 17
lcom 2
cbo 1
dl 0
loc 217
ccs 44
cts 44
cp 1
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A setId() 0 6 1
A getId() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A setScreenName() 0 6 1
A getScreenName() 0 4 1
A setProfileImageUrl() 0 6 1
A getProfileImageUrl() 0 4 1
A setProfileImageUrlHttps() 0 6 1
A getProfileImageUrlHttps() 0 4 1
A getProfileImageUrlHttpOrHttps() 0 9 2
A getTweets() 0 4 1
A addTweet() 0 6 1
A setValues() 0 9 1
1
<?php
2
3
namespace AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
7
/**
8
 * User.
9
 */
10
class User
11
{
12
    /**
13
     * @var int
14
     */
15
    private $id;
16
17
    /**
18
     * @var string
19
     */
20
    private $name;
21
22
    /**
23
     * @var string
24
     */
25
    private $screen_name;
26
27
    /**
28
     * @var string
29
     */
30
    private $profile_image_url;
31
32
    /**
33
     * @var string
34
     */
35
    private $profile_image_url_https;
36
37
    /**
38
     * @var ArrayCollection
39
     */
40
    private $tweets;
41
42 9
    public function __construct($id = null)
43
    {
44 9
        if (!is_null($id)) {
45 4
            $this->setId($id);
46
        }
47
48 9
        $this->tweets = new ArrayCollection();
49 9
    }
50
51
    /**
52
     * Set id.
53
     *
54
     * @param int $id
55
     *
56
     * @return User
57
     */
58 9
    public function setId($id)
59
    {
60 9
        $this->id = $id;
61
62 9
        return $this;
63
    }
64
65
    /**
66
     * Get id.
67
     *
68
     * @return int
69
     */
70 1
    public function getId()
71
    {
72 1
        return $this->id;
73
    }
74
75
    /**
76
     * Set name.
77
     *
78
     * @param string $name
79
     *
80
     * @return User
81
     */
82 9
    public function setName($name)
83
    {
84 9
        $this->name = $name;
85
86 9
        return $this;
87
    }
88
89
    /**
90
     * Get name.
91
     *
92
     * @return string
93
     */
94 10
    public function getName()
95
    {
96 10
        return $this->name;
97
    }
98
99
    /**
100
     * Set screen_name.
101
     *
102
     * @param string $screenName
103
     *
104
     * @return User
105
     */
106 9
    public function setScreenName($screenName)
107
    {
108 9
        $this->screen_name = $screenName;
109
110 9
        return $this;
111
    }
112
113
    /**
114
     * Get screen_name.
115
     *
116
     * @return string
117
     */
118 7
    public function getScreenName()
119
    {
120 7
        return $this->screen_name;
121
    }
122
123
    /**
124
     * Set profile_image_url.
125
     *
126
     * @param string $profileImageUrl
127
     *
128
     * @return User
129
     */
130 1
    public function setProfileImageUrl($profileImageUrl)
131
    {
132 1
        $this->profile_image_url = $profileImageUrl;
133
134 1
        return $this;
135
    }
136
137
    /**
138
     * Get profile_image_url.
139
     *
140
     * @return string
141
     */
142 2
    public function getProfileImageUrl()
143
    {
144 2
        return $this->profile_image_url;
145
    }
146
147
    /**
148
     * Set profile_image_url_https.
149
     *
150
     * @param string $profileImageUrlHttps
151
     *
152
     * @return User
153
     */
154 8
    public function setProfileImageUrlHttps($profileImageUrlHttps)
155
    {
156 8
        $this->profile_image_url_https = $profileImageUrlHttps;
157
158 8
        return $this;
159
    }
160
161
    /**
162
     * Get profile_image_url_https.
163
     *
164
     * @return string
165
     */
166 9
    public function getProfileImageUrlHttps()
167
    {
168 9
        return $this->profile_image_url_https;
169
    }
170
171
    /**
172
     * Get profile image, with HTTPS if available.
173
     *
174
     * @return string
175
     */
176 8
    public function getProfileImageUrlHttpOrHttps()
177
    {
178 8
        if (!is_null($this->getProfileImageUrlHttps())) {
179 8
            return $this->getProfileImageUrlHttps();
180
        }
181
        // else
182
183 1
        return $this->getProfileImageUrl();
184
    }
185
186
    /**
187
     * Get tweets.
188
     *
189
     * @return ArrayCollection
190
     */
191 1
    public function getTweets()
192
    {
193 1
        return $this->tweets;
194
    }
195
196
    /**
197
     * Add a tweet.
198
     *
199
     * @param Tweet $tweet
200
     *
201
     * @return User
202
     */
203 7
    public function addTweet(Tweet $tweet)
204
    {
205 7
        $this->tweets->add($tweet);
206
207 7
        return $this;
208
    }
209
210
    /**
211
     * Call setter functions.
212
     *
213
     * @param \stdClass $userTmp
214
     *
215
     * @return User
216
     */
217 3
    public function setValues(\stdClass $userTmp)
218
    {
219
        $this
220 3
            ->setName($userTmp->name)
221 3
            ->setScreenName($userTmp->screen_name)
222 3
            ->setProfileImageUrlHttps($userTmp->profile_image_url_https);
223
224 3
        return $this;
225
    }
226
}
227