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.

UserTrait   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 110
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 12
c 1
b 0
f 0
dl 0
loc 110
ccs 28
cts 28
cp 1
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A addRole() 0 3 1
A roles() 0 3 1
A data() 0 2 1
A removeRole() 0 3 1
A addGroup() 0 3 1
A tags() 0 3 1
A addTag() 0 3 1
A removeGroup() 0 3 1
A setDataProviderId() 0 3 1
A groups() 0 3 1
A removeTag() 0 3 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
namespace BristolSU\ControlDB\Traits;
5
6
7
use BristolSU\ControlDB\Contracts\Models\DataUser;
8
use BristolSU\ControlDB\Contracts\Models\Role;
9
use BristolSU\ControlDB\Contracts\Repositories\Pivots\Tags\UserUserTag;
10
use BristolSU\ControlDB\Contracts\Repositories\Pivots\UserGroup;
11
use BristolSU\ControlDB\Contracts\Repositories\Pivots\UserRole;
12
use BristolSU\ControlDB\Contracts\Repositories\User;
13
use BristolSU\ControlDB\Models\Group;
14
use BristolSU\ControlDB\Models\Tags\UserTag;
15
use Illuminate\Support\Collection;
16
17
/**
18
 * Implements common methods using repositories required by the user model interface
19
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
20
trait UserTrait
21
{
22
23
    /**
24
     * Get the attributes for this user
25
     *
26
     * @return DataUser
27
     */
28 15
    public function data(): DataUser {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
29 15
        return app(\BristolSU\ControlDB\Contracts\Repositories\DataUser::class)->getById($this->dataProviderId());
0 ignored issues
show
Bug introduced by
It seems like dataProviderId() 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

29
        return app(\BristolSU\ControlDB\Contracts\Repositories\DataUser::class)->getById($this->/** @scrutinizer ignore-call */ dataProviderId());
Loading history...
30
    }
31
32
    /**
33
     * Set the ID of the data provider
34
     *
35
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
36
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
37 2
    public function setDataProviderId(int $dataProviderId): void
38
    {
39 2
        app(User::class)->update($this->id(), $dataProviderId);
0 ignored issues
show
Bug introduced by
It seems like id() 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

39
        app(User::class)->update($this->/** @scrutinizer ignore-call */ id(), $dataProviderId);
Loading history...
40 2
    }
41
    
42
    /**
43
     * Tags the user is tagged with
44
     *
45
     * @return Collection
46
     */
47 2
    public function tags(): Collection
48
    {
49 2
        return app(UserUserTag::class)->getTagsThroughUser($this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...g::getTagsThroughUser(). ( Ignorable by Annotation )

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

49
        return app(UserUserTag::class)->getTagsThroughUser(/** @scrutinizer ignore-type */ $this);
Loading history...
50
    }
51
52
    /**
53
     * Roles the user owns
54
     *
55
     * @return Collection
56
     */
57 2
    public function roles(): Collection
58
    {
59 2
        return app(UserRole::class)->getRolesThroughUser($this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...::getRolesThroughUser(). ( Ignorable by Annotation )

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

59
        return app(UserRole::class)->getRolesThroughUser(/** @scrutinizer ignore-type */ $this);
Loading history...
60
    }
61
62
    /**
63
     * Groups the user is a member of
64
     *
65
     * @return Collection
66
     */
67 2
    public function groups(): Collection
68
    {
69 2
        return app(UserGroup::class)->getGroupsThroughUser($this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...:getGroupsThroughUser(). ( Ignorable by Annotation )

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

69
        return app(UserGroup::class)->getGroupsThroughUser(/** @scrutinizer ignore-type */ $this);
Loading history...
70
    }
71
72
    /**
73
     * Add a tag to the user
74
     * 
75
     * @param \BristolSU\ControlDB\Contracts\Models\Tags\UserTag $userTag
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
76
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
77 6
    public function addTag(\BristolSU\ControlDB\Contracts\Models\Tags\UserTag $userTag): void
78
    {
79 6
        app(UserUserTag::class)->addTagToUser($userTag, $this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...UserTag::addTagToUser(). ( Ignorable by Annotation )

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

79
        app(UserUserTag::class)->addTagToUser($userTag, /** @scrutinizer ignore-type */ $this);
Loading history...
80 6
    }
81
82
    /**
83
     * Remove a tag from the user
84
     * 
85
     * @param \BristolSU\ControlDB\Contracts\Models\Tags\UserTag $userTag
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
86
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
87 2
    public function removeTag(\BristolSU\ControlDB\Contracts\Models\Tags\UserTag $userTag): void
88
    {
89 2
        app(UserUserTag::class)->removeTagFromUser($userTag, $this);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...ag::removeTagFromUser(). ( Ignorable by Annotation )

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

89
        app(UserUserTag::class)->removeTagFromUser($userTag, /** @scrutinizer ignore-type */ $this);
Loading history...
90 2
    }
91
92
    /**
93
     * Add a role to the user
94
     * 
95
     * @param Role $role
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
96
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
97 5
    public function addRole(Role $role): void
98
    {
99 5
        app(UserRole::class)->addUserToRole($this, $role);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...erRole::addUserToRole(). ( Ignorable by Annotation )

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

99
        app(UserRole::class)->addUserToRole(/** @scrutinizer ignore-type */ $this, $role);
Loading history...
100 5
    }
101
102
    /**
103
     * Remove a role from the user
104
     * 
105
     * @param Role $role
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
106
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
107 2
    public function removeRole(Role $role): void
108
    {
109 2
        app(UserRole::class)->removeUserFromRole($this, $role);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...e::removeUserFromRole(). ( Ignorable by Annotation )

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

109
        app(UserRole::class)->removeUserFromRole(/** @scrutinizer ignore-type */ $this, $role);
Loading history...
110 2
    }
111
112
    /**
113
     * Add a group to the user
114
     * 
115
     * @param \BristolSU\ControlDB\Contracts\Models\Group $group
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
116
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
117 5
    public function addGroup(\BristolSU\ControlDB\Contracts\Models\Group $group): void
118
    {
119 5
        app(UserGroup::class)->addUserToGroup($this, $group);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...Group::addUserToGroup(). ( Ignorable by Annotation )

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

119
        app(UserGroup::class)->addUserToGroup(/** @scrutinizer ignore-type */ $this, $group);
Loading history...
120 5
    }
121
122
    /**
123
     * Remove a group from the user
124
     * 
125
     * @param \BristolSU\ControlDB\Contracts\Models\Group $group
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
126
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
127 2
    public function removeGroup(\BristolSU\ControlDB\Contracts\Models\Group $group): void
128
    {
129 2
        app(UserGroup::class)->removeUserFromGroup($this, $group);
0 ignored issues
show
Bug introduced by
$this of type BristolSU\ControlDB\Traits\UserTrait is incompatible with the type BristolSU\ControlDB\Contracts\Models\User expected by parameter $user of BristolSU\ControlDB\Cont...::removeUserFromGroup(). ( Ignorable by Annotation )

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

129
        app(UserGroup::class)->removeUserFromGroup(/** @scrutinizer ignore-type */ $this, $group);
Loading history...
130 2
    }
131
    
132
    
133
}