UserRelationship   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sessions() 0 3 1
A providers() 0 3 1
A roles() 0 6 1
1
<?php
2
3
namespace App\Models\Access\User\Traits\Relationship;
4
5
use App\Models\Access\User\SocialLogin;
6
use App\Models\System\Session;
7
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
8
use Illuminate\Database\Eloquent\Relations\HasMany;
9
10
/**
11
 * Class UserRelationship.
12
 */
13
trait UserRelationship
14
{
15
    public function roles(): ?BelongsToMany
16
    {
17
        return $this->belongsToMany(config('access.role'),
0 ignored issues
show
Bug introduced by
It seems like belongsToMany() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        return $this->/** @scrutinizer ignore-call */ belongsToMany(config('access.role'),
Loading history...
18
            config('access.role_user_table'),
19
            'user_id',
20
            'role_id');
21
    }
22
23
    public function providers(): ?HasMany
24
    {
25
        return $this->hasMany(SocialLogin::class);
0 ignored issues
show
Bug introduced by
It seems like hasMany() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        return $this->/** @scrutinizer ignore-call */ hasMany(SocialLogin::class);
Loading history...
26
    }
27
28
    public function sessions(): ?HasMany
29
    {
30
        return $this->hasMany(Session::class);
31
    }
32
}
33