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: public function __construct($id = null)
43: {
44: if (!is_null($id)) {
45: $this->setId($id);
46: }
47:
48: $this->tweets = new ArrayCollection();
49: }
50:
51: /**
52: * Set id.
53: *
54: * @param int $id
55: *
56: * @return User
57: */
58: public function setId($id)
59: {
60: $this->id = $id;
61:
62: return $this;
63: }
64:
65: /**
66: * Get id.
67: *
68: * @return int
69: */
70: public function getId()
71: {
72: return $this->id;
73: }
74:
75: /**
76: * Set name.
77: *
78: * @param string $name
79: *
80: * @return User
81: */
82: public function setName($name)
83: {
84: $this->name = $name;
85:
86: return $this;
87: }
88:
89: /**
90: * Get name.
91: *
92: * @return string
93: */
94: public function getName()
95: {
96: return $this->name;
97: }
98:
99: /**
100: * Set screen_name.
101: *
102: * @param string $screenName
103: *
104: * @return User
105: */
106: public function setScreenName($screenName)
107: {
108: $this->screen_name = $screenName;
109:
110: return $this;
111: }
112:
113: /**
114: * Get screen_name.
115: *
116: * @return string
117: */
118: public function getScreenName()
119: {
120: return $this->screen_name;
121: }
122:
123: /**
124: * Set profile_image_url.
125: *
126: * @param string $profileImageUrl
127: *
128: * @return User
129: */
130: public function setProfileImageUrl($profileImageUrl)
131: {
132: $this->profile_image_url = $profileImageUrl;
133:
134: return $this;
135: }
136:
137: /**
138: * Get profile_image_url.
139: *
140: * @return string
141: */
142: public function getProfileImageUrl()
143: {
144: 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: public function setProfileImageUrlHttps($profileImageUrlHttps)
155: {
156: $this->profile_image_url_https = $profileImageUrlHttps;
157:
158: return $this;
159: }
160:
161: /**
162: * Get profile_image_url_https.
163: *
164: * @return string
165: */
166: public function getProfileImageUrlHttps()
167: {
168: return $this->profile_image_url_https;
169: }
170:
171: /**
172: * Get profile image, with HTTPS if available.
173: *
174: * @return string
175: */
176: public function getProfileImageUrlHttpOrHttps()
177: {
178: if (!is_null($this->getProfileImageUrlHttps())) {
179: return $this->getProfileImageUrlHttps();
180: }
181: // else
182:
183: return $this->getProfileImageUrl();
184: }
185:
186: /**
187: * Get tweets.
188: *
189: * @return ArrayCollection
190: */
191: public function getTweets()
192: {
193: return $this->tweets;
194: }
195:
196: /**
197: * Add a tweet.
198: *
199: * @param Tweet $tweet
200: *
201: * @return User
202: */
203: public function addTweet(Tweet $tweet)
204: {
205: $this->tweets->add($tweet);
206:
207: return $this;
208: }
209:
210: /**
211: * Call setter functions.
212: *
213: * @param \stdClass $userTmp
214: *
215: * @return User
216: */
217: public function setValues(\stdClass $userTmp)
218: {
219: $this
220: ->setName($userTmp->name)
221: ->setScreenName($userTmp->screen_name)
222: ->setProfileImageUrlHttps($userTmp->profile_image_url_https);
223:
224: return $this;
225: }
226: }
227: