Completed
Push — master ( 4ffd06...6a7f3a )
by
unknown
05:19
created

User::getLanguageCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace TelegramBot\Api\Types;
4
5
use TelegramBot\Api\BaseType;
6
use TelegramBot\Api\InvalidArgumentException;
7
use TelegramBot\Api\TypeInterface;
8
9
/**
10
 * Class User
11
 * This object represents a Telegram user or bot.
12
 *
13
 * @package TelegramBot\Api\Types
14
 */
15
class User extends BaseType implements TypeInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     *
20
     * @var array
21
     */
22
    static protected $requiredParams = ['id', 'first_name'];
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * @var array
28
     */
29
    static protected $map = [
30
        'id' => true,
31
        'first_name' => true,
32
        'last_name' => true,
33
        'username' => true,
34
        'language_code' => true,
35
        'is_bot' => true
36
    ];
37
38
    /**
39
     * Unique identifier for this user or bot
40
     *
41
     * @var int
42
     */
43
    protected $id;
44
45
    /**
46
     * User‘s or bot’s first name
47
     *
48
     * @var string
49
     */
50
    protected $firstName;
51
52
    /**
53
     * Optional. User‘s or bot’s last name
54
     *
55
     * @var string
56
     */
57
    protected $lastName;
58
59
    /**
60
     * Optional. User‘s or bot’s username
61
     *
62
     * @var string
63
     */
64
    protected $username;
65
66
    /**
67
     * Optional. IETF language tag of the user's language
68
     *
69
     * @var string
70
     */
71
    protected $languageCode;
72
73
    /**
74
     * True, if this user is a bot
75
     *
76
     * @var bool
77
     */
78
    protected $isBot;
79
80
    /**
81
     * @return string
82
     */
83 2
    public function getFirstName()
84
    {
85 2
        return $this->firstName;
86
    }
87
88
    /**
89
     * @param string $firstName
90
     */
91 32
    public function setFirstName($firstName)
92
    {
93 32
        $this->firstName = $firstName;
94 32
    }
95
96
    /**
97
     * @return int
98
     */
99 2
    public function getId()
100
    {
101 2
        return $this->id;
102
    }
103
104
    /**
105
     * @param int $id
106
     *
107
     * @throws InvalidArgumentException
108
     */
109 34
    public function setId($id)
110
    {
111 34
        if (is_integer($id) || is_float($id)) {
112 33
            $this->id = $id;
0 ignored issues
show
Documentation Bug introduced by
It seems like $id can also be of type double. However, the property $id is declared as type integer. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
113 33
        } else {
114 1
            throw new InvalidArgumentException();
115
        }
116 33
    }
117
118
    /**
119
     * @return string
120
     */
121 2
    public function getLastName()
122
    {
123 2
        return $this->lastName;
124
    }
125
126
    /**
127
     * @param string $lastName
128
     */
129 32
    public function setLastName($lastName)
130
    {
131 32
        $this->lastName = $lastName;
132 32
    }
133
134
    /**
135
     * @return string
136
     */
137 2
    public function getUsername()
138
    {
139 2
        return $this->username;
140
    }
141
142
    /**
143
     * @param string $username
144
     */
145 32
    public function setUsername($username)
146
    {
147 32
        $this->username = $username;
148 32
    }
149
150
    /**
151
     * @return string
152
     */
153
    public function getLanguageCode()
154
    {
155
        return $this->languageCode;
156
    }
157
158
    /**
159
     * @param string $languageCode
160
     */
161
    public function setLanguageCode($languageCode)
162
    {
163
        $this->languageCode = $languageCode;
164
    }
165
166
    /**
167
     * @return bool
168
     */
169
    public function isBot()
170
    {
171
        return $this->isBot;
172
    }
173
174
    /**
175
     * @param bool $isBot
176
     */
177
    public function setIsBot($isBot)
178
    {
179
        $this->isBot = $isBot;
180
    }
181
}
182