Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Failed
Push — development ( a51bef...1aad8e )
by José
08:14
created

User::getIsActiveAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace DoeSangue\Models;
4
5
use Illuminate\Notifications\Notifiable;
6
use Illuminate\Foundation\Auth\User as Authenticatable;
7
use DoeSangue\Models\Campaign;
8
use DoeSangue\Models\Donor;
9
use DoeSangue\Models\Invite;
10
use DoeSangue\Models\Comment;
11
12
class User extends Authenticatable
13
{
14
    use Notifiable;
15
16
    /**
17
     * The attributes that are mass assignable.
18
     *
19
     * @var array
20
     */
21
    protected $fillable = [
22
                            'first_name',
23
                            'last_name',
24
                            'email',
25
                            'username',
26
                            'phone',
27
                            'bio',
28
                            'birthdate',
29
                            'active',
30
                            'password',
31
                          ];
32
33
    /**
34
     * The attributes that should be hidden for arrays.
35
     *
36
     * @var array
37
     */
38
    protected $hidden = [
39
                          'password',
40
                          'remember_token',
41
                          'created_at',
42
                          'updated_at',
43
                          'deleted_at',
44
                          'id',
45
                          'phone',
46
                          'active'
47
                        ];
48
49
    /**
50
     * The dates attributes.
51
     *
52
     * @var array $dates
53
     */
54
    protected $dates = [
55
      'created_at', 'updated_at', 'deleted_at'
56
    ];
57
58
    protected $appends = [ 'is_active' ];
59
60
    /**
61
     * Returns the full name of user.
62
     *
63
     * @return string
64
     */
65
    public function getFullNameAttribute($value)
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
    {
67
        return ucfirst($this->first_name) . ' ' . ucfirst($this->last_name);
0 ignored issues
show
Documentation introduced by
The property first_name does not exist on object<DoeSangue\Models\User>. 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...
Documentation introduced by
The property last_name does not exist on object<DoeSangue\Models\User>. 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...
68
    }
69
70
    /**
71
     * Returns the campaigns created by the user.
72
     *
73
     * @return array relationship
74
     * @var    array
75
     */
76
    public function campaigns()
77
    {
78
        return $this->hasMany(Campaign::class);
79
    }
80
81
    public function donor()
82
    {
83
        return $this->hasOne(Donor::class);
84
    }
85
86
    /**
87
     * Return as Many invites created by user.
88
     */
89
    public function invites()
90
    {
91
        return $this->hasMany(Invite::class);
92
    }
93
94
    /**
95
     * Returns the comments created by the user.
96
     *
97
     * @return array relationship
98
     * @var    array
99
     */
100
    public function comments()
101
    {
102
        return $this->hasMany(Comment::class);
103
    }
104
105
    public function getIsActiveAttribute()
106
    {
107
        return $this->attributes['active'] == true;
108
    }
109
}
110