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 Lab404\AuthChecker\Services; |
||
4 | |||
5 | use Carbon\Carbon; |
||
6 | use Illuminate\Config\Repository as Config; |
||
7 | use Illuminate\Contracts\Auth\Authenticatable; |
||
8 | use Illuminate\Database\Eloquent\Model; |
||
9 | use Illuminate\Foundation\Application; |
||
10 | use Illuminate\Http\Request; |
||
11 | use Jenssegers\Agent\Agent; |
||
12 | use Lab404\AuthChecker\Events\DeviceCreated; |
||
13 | use Lab404\AuthChecker\Events\LoginCreated; |
||
14 | use Lab404\AuthChecker\Models\Device; |
||
15 | use Lab404\AuthChecker\Models\Login; |
||
16 | |||
17 | class AuthChecker |
||
18 | { |
||
19 | /** @var Application */ |
||
20 | private $app; |
||
21 | |||
22 | /** @var Request */ |
||
23 | private $request; |
||
24 | |||
25 | /** @var Config */ |
||
26 | private $config; |
||
27 | |||
28 | /** |
||
29 | * AuthChecker |
||
30 | * |
||
31 | * @param Application $app |
||
32 | */ |
||
33 | public function __construct(Application $app, Request $request) |
||
34 | { |
||
35 | $this->app = $app; |
||
36 | $this->request = $request; |
||
37 | $this->config = $app['config']; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @param Authenticatable $user |
||
42 | * @return void |
||
43 | */ |
||
44 | public function handleLogin(Authenticatable $user) |
||
45 | { |
||
46 | $agent = $this->app['agent']; |
||
47 | $device = $this->findOrCreateUserDeviceByAgent($user, $agent); |
||
48 | |||
49 | if ($this->shouldLogDeviceLogin($device)) { |
||
0 ignored issues
–
show
|
|||
50 | $this->createUserLoginForDevice($user, $device); |
||
0 ignored issues
–
show
It seems like
$device defined by $this->findOrCreateUserD...eByAgent($user, $agent) on line 47 can be null ; however, Lab404\AuthChecker\Servi...ateUserLoginForDevice() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
Loading history...
|
|||
51 | } |
||
52 | |||
53 | if ($device->wasRecentlyCreated) { |
||
54 | event(DeviceCreated::class); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param Authenticatable $user |
||
60 | * @param Agent $agent |
||
61 | * @return Device|null |
||
62 | */ |
||
63 | public function findOrCreateUserDeviceByAgent(Authenticatable $user, Agent $agent) |
||
64 | { |
||
65 | $device = $this->findUserDeviceByAgent($user, $agent); |
||
66 | |||
67 | if (is_null($device)) { |
||
68 | $device = $this->createUserDeviceByAgent($user, $agent); |
||
69 | } |
||
70 | |||
71 | return $device; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @param Authenticatable $user |
||
76 | * @param Agent $agent |
||
77 | * @return Device|null |
||
78 | */ |
||
79 | View Code Duplication | public function findUserDeviceByAgent(Authenticatable $user, Agent $agent) |
|
80 | { |
||
81 | if (!$user->hasDevices()) { |
||
82 | return null; |
||
83 | } |
||
84 | |||
85 | $matching = $user->devices->filter(function ($item) use ($agent) { |
||
86 | return $this->deviceMatch($item, $agent); |
||
87 | })->first(); |
||
88 | |||
89 | return $matching ? $matching : null; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @param Model $user |
||
94 | * @param Agent $agent |
||
95 | * @return Device |
||
96 | */ |
||
97 | public function createUserDeviceByAgent(Model $user, Agent $agent) |
||
98 | { |
||
99 | $device = new Device(); |
||
100 | |||
101 | $device->platform = $agent->platform(); |
||
0 ignored issues
–
show
The property
platform does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
102 | $device->platform_version = $agent->version($device->platform); |
||
0 ignored issues
–
show
The property
platform_version does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
The property
platform does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
103 | $device->browser = $agent->browser(); |
||
0 ignored issues
–
show
The property
browser does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
104 | $device->browser_version = $agent->version($device->browser); |
||
0 ignored issues
–
show
The property
browser_version does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
The property
browser does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
105 | $device->is_desktop = $agent->isDesktop() ? true : false; |
||
0 ignored issues
–
show
The property
is_desktop does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
106 | $device->is_mobile = $agent->isMobile() ? true : false; |
||
0 ignored issues
–
show
The property
is_mobile does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
107 | $device->language = count($agent->languages()) ? $agent->languages()[0] : null; |
||
0 ignored issues
–
show
The property
language does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
108 | $device->user_id = $user->getKey(); |
||
109 | |||
110 | $device->save(); |
||
111 | |||
112 | return $device; |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * @param Model $user |
||
117 | * @param Device $device |
||
118 | * @return Login |
||
119 | */ |
||
120 | public function createUserLoginForDevice(Model $user, Device $device) |
||
121 | { |
||
122 | $ip = $this->request->ip(); |
||
123 | |||
124 | $login = new Login(['user_id' => $user->getKey(), 'ip_address' => $ip, 'device_id' => $device->id]); |
||
0 ignored issues
–
show
The property
id does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
125 | event(new LoginCreated($login)); |
||
126 | |||
127 | return $login; |
||
128 | } |
||
129 | |||
130 | /** |
||
131 | * @param Model $user |
||
132 | * @param Agent $agent |
||
133 | * @return false|Device |
||
134 | */ |
||
135 | View Code Duplication | public function findDeviceForUser(Model $user, Agent $agent) |
|
136 | { |
||
137 | if (!$user->hasDevices()) { |
||
138 | return false; |
||
139 | } |
||
140 | |||
141 | $device = $user->devices->filter(function ($item) use ($agent) { |
||
142 | return $this->deviceMatch($item, $agent); |
||
143 | })->first(); |
||
144 | |||
145 | return is_null($device) ? false : $device; |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * @param Device $device |
||
150 | * @return bool |
||
151 | */ |
||
152 | public function shouldLogDeviceLogin(Device $device) |
||
153 | { |
||
154 | $throttle = $this->getLoginThrottle(); |
||
155 | |||
156 | if (!$device->relationLoaded('login')) { |
||
157 | $device->load('login'); |
||
158 | } |
||
159 | |||
160 | if ($throttle === 0 || is_null($device->login)) { |
||
0 ignored issues
–
show
The property
login does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
161 | return true; |
||
162 | } |
||
163 | |||
164 | $limit = Carbon::now()->subMinutes($throttle); |
||
165 | $login = $device->login; |
||
0 ignored issues
–
show
The property
login does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
166 | |||
167 | if (isset($login->created_at) && $login->created_at->gt($limit)) { |
||
168 | return false; |
||
169 | } |
||
170 | |||
171 | return true; |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @param Device $device |
||
176 | * @param Agent $agent |
||
177 | * @return bool |
||
178 | */ |
||
179 | public function deviceMatch(Device $device, Agent $agent, array $attributes = null) |
||
180 | { |
||
181 | $attributes = is_null($attributes) ? $this->getDeviceMatchingAttributes() : $attributes; |
||
182 | $matches = count($attributes) > 0 ? false : true; |
||
183 | |||
184 | if (in_array('platform', $attributes)) { |
||
185 | $matches = $device->platform === $agent->platform(); |
||
0 ignored issues
–
show
The property
platform does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
186 | } |
||
187 | |||
188 | if (in_array('platform_version', $attributes)) { |
||
189 | $matches = $device->platform_version === $agent->version($device->platform); |
||
0 ignored issues
–
show
The property
platform_version does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
The property
platform does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
190 | } |
||
191 | |||
192 | if (in_array('browser', $attributes)) { |
||
193 | $matches = $device->browser === $agent->browser(); |
||
0 ignored issues
–
show
The property
browser does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
194 | } |
||
195 | |||
196 | if (in_array('browser_version', $attributes)) { |
||
197 | $matches = $device->browser_version === $agent->version($device->browser); |
||
0 ignored issues
–
show
The property
browser_version does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
The property
browser does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
198 | } |
||
199 | |||
200 | if (in_array('language', $attributes)) { |
||
201 | $matches = $device->language === $agent->version($device->language); |
||
0 ignored issues
–
show
The property
language does not exist on object<Lab404\AuthChecker\Models\Device> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
202 | } |
||
203 | |||
204 | return $matches; |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * @param void |
||
209 | * @return array |
||
210 | */ |
||
211 | public function getDeviceMatchingAttributes() |
||
212 | { |
||
213 | return $this->config->get('laravel-auth-checker.device_matching_attributes', [ |
||
214 | 'ip', |
||
215 | 'platform', |
||
216 | 'platform_version', |
||
217 | 'browser', |
||
218 | ]); |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * @param void |
||
223 | * @return int |
||
224 | */ |
||
225 | public function getLoginThrottle() |
||
226 | { |
||
227 | return (int)$this->config->get('laravel-auth-checker.throttle', 0); |
||
228 | } |
||
229 | } |
||
230 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: