GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

User   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getLocaleAttribute() 0 6 1
A getLocaleKendoAttribute() 0 8 1
A getLocaleMomentAttribute() 0 13 3
A getLanguageAttribute() 0 7 1
A getApiTokenAttribute() 0 10 2
A accounts() 0 4 1
A payees() 0 4 1
A categories() 0 4 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Foundation\Auth\User as Authenticatable;
6
use Illuminate\Notifications\Notifiable;
7
8
class User extends Authenticatable
9
{
10
    use Notifiable;
11
12
    private $defaultLocale = 'en_US';
13
14
    /**
15
     * The attributes that are mass assignable.
16
     *
17
     * @var array
18
     */
19
    protected $fillable = [
20
        'name', 'email', 'password', 'mmex_guid',
21
    ];
22
23
    /**
24
     * The attributes that should be hidden for arrays.
25
     *
26
     * @var array
27
     */
28
    protected $hidden = [
29
        'password', 'remember_token',
30
    ];
31
32
    public function isAdmin()
33
    {
34
        return $this->attributes['is_admin'];
35
    }
36
37
    public function getLocaleAttribute()
38
    {
39
        $locale = $this->attributes['locale'] ?? $this->defaultLocale;
40
41
        return $locale;
42
    }
43
44
    public function getLocaleKendoAttribute()
45
    {
46
        $locale = $this->locale;
47
48
        $locale = str_replace('_', '-', $locale);
49
50
        return $locale;
51
    }
52
53
    public function getLocaleMomentAttribute()
54
    {
55
        $locale = $this->locale;
56
57
        $locale = str_replace('_', '-', $locale);
58
        $locale = strtolower($locale);
59
60
        // TODO: ugly workaround for different locale styles
61
        $locale = $locale == 'de-de' ? 'de' : $locale;
62
        $locale = $locale == 'en-us' ? 'en' : $locale;
63
64
        return $locale;
65
    }
66
67
    public function getLanguageAttribute()
68
    {
69
        $locale = $this->locale;
70
        $language = explode('_', $locale)[0];
71
72
        return $language;
73
    }
74
75
    public function getApiTokenAttribute($value)
76
    {
77
        if (empty($value)) {
78
            $value = str_random(60);
79
            $this->api_token = $value;
80
            $this->save();
81
        }
82
83
        return $value;
84
    }
85
86
    /**
87
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
88
     */
89
    public function transactions()
90
    {
91
        return $this->hasMany(Transaction::class);
92
    }
93
94
    /**
95
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
96
     */
97
    public function accounts()
98
    {
99
        return $this->hasMany(Account::class);
100
    }
101
102
    /**
103
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
104
     */
105
    public function payees()
106
    {
107
        return $this->hasMany(Payee::class);
108
    }
109
110
    /**
111
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
112
     */
113
    public function categories()
114
    {
115
        return $this->hasMany(Category::class);
116
    }
117
}
118