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

Completed
Push — master ( 183370...557c6a )
by Mark
02:40
created

Account   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Coupling/Cohesion

Components 3
Dependencies 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 110
rs 10
wmc 10
lcom 3
cbo 3

9 Methods

Rating   Name   Duplication   Size   Complexity  
A fullName() 0 4 1
A hasRole() 0 4 1
A makeGravatarImage() 0 4 1
A pages() 0 4 1
A menus() 0 4 1
A articles() 0 4 1
A role() 0 4 1
A redirects() 0 8 2
A setPassword() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Mark
5
 * Date: 11/03/2016
6
 * Time: 14:07.
7
 */
8
9
namespace App\Model;
10
11
use Carbon\Carbon;
12
use Illuminate\Database\Eloquent\SoftDeletes;
13
use Illuminate\Database\Eloquent\Relations\HasMany;
14
use Illuminate\Database\Eloquent\Relations\BelongsTo;
15
use Illuminate\Foundation\Auth\User as Authenticatable;
16
17
/**
18
 * Class Accounts.
19
 *
20
 * @property Role role
21
 *
22
 * @property HasMany $pages
23
 * @property HasMany $articles
24
 * @property HasMany $menus
25
 * @property HasMany $redirects
26
 *
27
 * @property Carbon $deleted_at
28
 * @property Carbon $last_login
29
 * @property Carbon $created_at
30
 * @property Carbon $updated_at
31
 *
32
 * @property int $id
33
 * @property string $email
34
 * @property string $password
35
 * @property string $remember_token
36
 * @property string $forename
37
 * @property string $surname
38
 * @property string $address
39
 * @property string $number
40
 * @property int $role_id
41
 * @property int $status
42
 * @property int $verified
43
 * @property int $login_count
44
 * @property string $ip_address
45
 */
46
class Account extends Authenticatable
47
{
48
    /*
49
     * Soft Delete trait
50
     */
51
    use SoftDeletes;
52
53
    /**
54
     * The table associated with the model.
55
     *
56
     * @var string
57
     */
58
    protected $table = 'accounts';
59
60
    /**
61
     * The attributes that should be mutated to dates.
62
     *
63
     * @var array
64
     */
65
    protected $dates = ['last_login', 'created_at'];
66
67
    /**
68
     * Return the full name of the account.
69
     *
70
     * @return string
71
     */
72
    public function fullName()
73
    {
74
        return $this->forename.' '.$this->surname;
75
    }
76
77
    /**
78
     * Check if the user has the role.
79
     * @info Role::groups.
80
     *
81
     * @param int $role_id
82
     * @param bool $rule
83
     * @return bool
84
     */
85
    public function hasRole(int $role_id, bool $rule = true)
0 ignored issues
show
Coding Style Naming introduced by
The parameter $role_id is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
86
    {
87
        return ($this->role->id() <= $role_id) == $rule;
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function makeGravatarImage()
94
    {
95
        return 'https://secure.gravatar.com/avatar/'.md5(strtolower(trim($this->email)));
96
    }
97
98
    /**
99
     * @return HasMany
100
     */
101
    public function pages()
102
    {
103
        return $this->hasMany(Page::class, 'creator_id', 'id');
104
    }
105
106
    /**
107
     * @return HasMany
108
     */
109
    public function menus()
110
    {
111
        return $this->hasMany(Menu::class, 'creator_id', 'id');
112
    }
113
114
    /**
115
     * @return HasMany
116
     */
117
    public function articles()
118
    {
119
        return $this->hasMany(Article::class, 'creator_id', 'id');
120
    }
121
122
    /**
123
     * @return Role|BelongsTo
124
     */
125
    public function role()
126
    {
127
        return $this->belongsTo(Role::class, 'role_id');
128
    }
129
130
    /**
131
     * Return the generated redirects by the user.
132
     *
133
     * @param array $attributes
134
     * @return Redirect|HasMany
135
     */
136
    public function redirects($attributes = [])
137
    {
138
        if (isset($attributes['modifier'])) {
139
            return $this->hasMany(Redirect::class, 'modifier_id', 'id');
140
        }
141
142
        return $this->hasMany(Redirect::class, 'creator_id', 'id');
143
    }
144
145
    /**
146
     * Generate a bCrpyt string for new password enties.
147
     *
148
     * @param string $string
149
     * @return $this
150
     */
151
    public function setPassword(string $string)
152
    {
153
        return $this->setAttribute('password', bcrypt($string));
154
    }
155
}
156