Completed
Push — master ( dd0ca4...f00659 )
by Julien
03:18
created

SuperAdminPolicy::isSuperAdmin()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4286
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
 * @package App\Policies
11
 */
12
class SuperAdminPolicy
13
{
14
15
    use HandlesAuthorization;
16
17
    /**
18
     * Determine if the given post can be updated by the user.
19
     * @return bool
20
     */
21
    public function isSuperAdmin(Administrators $administrator)
22
    {
23
        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...
24
            return true;
25
        }else{
26
            return false;
27
        }
28
    }
29
30
31
    /**
32
     * Determine if the given post can be updated by the user.
33
     * @return bool
34
     */
35
    public function isExpired(Administrators $administrator)
36
    {
37
38
        // si j'ai expiration au niveau des date d'expiratio n
39
        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...
40
            return true;
41
        }else{
42
            return false;
43
        }
44
    }
45
46
}
47