SuperAdminPolicy::isExpired()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
namespace App\Policies;
4
5
use App\Http\Models\Administrators;
6
use Illuminate\Auth\Access\HandlesAuthorization;
7
8
/**
9
 * Class SuperAdminPolicy.
10
 */
11
class SuperAdminPolicy
12
{
13
    use HandlesAuthorization;
14
15
    /**
16
     * Determine if the given post can be updated by the user.
17
     *
18
     * @return bool
19
     */
20
    public function isSuperAdmin(Administrators $administrator)
21
    {
22
        if ($administrator->super_admin === true) {
0 ignored issues
show
Documentation introduced by
The property super_admin does not exist on object<App\Http\Models\Administrators>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?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...
23
            return true;
24
        } else {
25
            return false;
26
        }
27
    }
28
29
    /**
30
     * Determine if the given post can be updated by the user.
31
     *
32
     * @return bool
33
     */
34
    public function isExpired(Administrators $administrator)
35
    {
36
37
        // si j'ai expiration au niveau des date d'expiratio n
38
        if ($administrator->expiration_date > date('Y-m-d')) {
0 ignored issues
show
Documentation introduced by
The property expiration_date does not exist on object<App\Http\Models\Administrators>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?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...
39
            return true;
40
        } else {
41
            return false;
42
        }
43
    }
44
}
45