Passed
Push — master ( a589f8...1929d3 )
by Alexis
01:42 queued 11s
created

src/Entity/User.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace AlexisLefebvre\Bundle\AsyncTweetsBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\Common\Collections\Collection;
7
8
/**
9
 * User.
10
 */
11
class User
12
{
13
    /**
14
     * @var int
15
     */
16
    private $id;
17
18
    /**
19
     * @var string
20
     */
21
    private $name;
22
23
    /**
24
     * @var string
25
     */
26
    private $screen_name;
27
28
    /**
29
     * @var string|null
30
     */
31
    private $profile_image_url;
32
33
    /**
34
     * @var string|null
35
     */
36
    private $profile_image_url_https;
37
38
    /**
39
     * @var Collection<int, Tweet>
40
     */
41
    private $tweets;
42
43 16
    public function __construct(?int $id = null)
44
    {
45 16
        if (!is_null($id)) {
46 4
            $this->setId($id);
47
        }
48
49 16
        $this->tweets = new ArrayCollection();
50 16
    }
51
52 16
    public function setId(int $id): self
53
    {
54 16
        $this->id = $id;
55
56 16
        return $this;
57
    }
58
59 1
    public function getId(): int
60
    {
61 1
        return $this->id;
62
    }
63
64
    /**
65
     * Set name.
66
     */
67 16
    public function setName(string $name): self
68
    {
69 16
        $this->name = $name;
70
71 16
        return $this;
72
    }
73
74
    /**
75
     * Get name.
76
     */
77 10
    public function getName(): string
78
    {
79 10
        return $this->name;
80
    }
81
82
    /**
83
     * Set screen_name.
84
     */
85 16
    public function setScreenName(string $screenName): self
86
    {
87 16
        $this->screen_name = $screenName;
88
89 16
        return $this;
90
    }
91
92
    /**
93
     * Get screen_name.
94
     */
95 7
    public function getScreenName(): string
96
    {
97 7
        return $this->screen_name;
98
    }
99
100
    /**
101
     * Set profile_image_url.
102
     */
103 1
    public function setProfileImageUrl(?string $profileImageUrl): self
104
    {
105 1
        $this->profile_image_url = $profileImageUrl;
106
107 1
        return $this;
108
    }
109
110
    /**
111
     * Get profile_image_url.
112
     */
113 2
    public function getProfileImageUrl(): ?string
114
    {
115 2
        return $this->profile_image_url;
116
    }
117
118
    /**
119
     * Set profile_image_url_https.
120
     */
121 15
    public function setProfileImageUrlHttps(?string $profileImageUrlHttps): self
122
    {
123 15
        $this->profile_image_url_https = $profileImageUrlHttps;
124
125 15
        return $this;
126
    }
127
128
    /**
129
     * Get profile_image_url_https.
130
     */
131 9
    public function getProfileImageUrlHttps(): ?string
132
    {
133 9
        return $this->profile_image_url_https;
134
    }
135
136
    /**
137
     * Get profile image, with HTTPS if available.
138
     */
139 8
    public function getProfileImageUrlHttpOrHttps(): ?string
140
    {
141 8
        if (!is_null($this->getProfileImageUrlHttps())) {
142 8
            return $this->getProfileImageUrlHttps();
143
        }
144
        // else
145
146 1
        return $this->getProfileImageUrl();
147
    }
148
149
    /**
150
     * Get tweets.
151
     *
152
     * @return Collection<int, Tweet>
0 ignored issues
show
The doc-type Collection<int, could not be parsed: Expected "|" or "end of type", but got "<" at position 10. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
153
     */
154 1
    public function getTweets(): Collection
155
    {
156 1
        return $this->tweets;
157
    }
158
159
    /**
160
     * Add a tweet.
161
     */
162 14
    public function addTweet(Tweet $tweet): self
163
    {
164 14
        $this->tweets->add($tweet);
165
166 14
        return $this;
167
    }
168
169
    /**
170
     * Call setter functions.
171
     */
172 3
    public function setValues(\stdClass $userTmp): self
173
    {
174
        $this
175 3
            ->setName($userTmp->name)
176 3
            ->setScreenName($userTmp->screen_name)
177 3
            ->setProfileImageUrlHttps($userTmp->profile_image_url_https);
178
179 3
        return $this;
180
    }
181
}
182