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.

RoleHasSpaceToAssign   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 50
ccs 14
cts 16
cp 0.875
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A passes() 0 11 3
A group() 0 3 1
A __construct() 0 5 1
A message() 0 3 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\AssignRoles\Rules;
4
5
use BristolSU\ControlDB\Contracts\Repositories\Role;
6
use BristolSU\Module\AssignRoles\Support\PositionSettingRetrieval;
7
use BristolSU\Support\Authentication\Contracts\Authentication;
8
use Illuminate\Contracts\Validation\Rule;
9
10
/**
11
 * Does the role given have space to assign?
12
 * 
13
 * This is not the case if the role should only have a single user, and it already has a user
14
 * 
15
 * @package BristolSU\Module\AssignRoles\Rules
16
 */
0 ignored issues
show
Coding Style introduced by
Missing @category 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...
17
class RoleHasSpaceToAssign implements Rule
18
{
19
20
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
     * @var PositionSettingRetrieval
22
     */
23
    private $positionSettingRetrieval;
0 ignored issues
show
Coding Style introduced by
Private member variable "positionSettingRetrieval" must be prefixed with an underscore
Loading history...
24
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
25
     * @var Authentication
26
     */
27
    private $authentication;
0 ignored issues
show
Coding Style introduced by
Private member variable "authentication" must be prefixed with an underscore
Loading history...
28
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
29
     * @var Role
30
     */
31
    private $roleRepository;
0 ignored issues
show
Coding Style introduced by
Private member variable "roleRepository" must be prefixed with an underscore
Loading history...
32
33 7
    public function __construct(Authentication $authentication, PositionSettingRetrieval $positionSettingRetrieval, Role $roleRepository)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
34
    {
35 7
        $this->positionSettingRetrieval = $positionSettingRetrieval;
36 7
        $this->authentication = $authentication;
37 7
        $this->roleRepository = $roleRepository;
38 7
    }
39
40
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $attribute should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $value should have a doc-comment as per coding-style.
Loading history...
41
     * @inheritDoc
42
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
43 7
    public function passes($attribute, $value)
44
    {
45
        try {
46 7
            $settings = $this->positionSettingRetrieval->getSettings($this->group());
0 ignored issues
show
Bug introduced by
It seems like $this->group() can also be of type null; however, parameter $group of BristolSU\Module\AssignR...etrieval::getSettings() does only seem to accept BristolSU\ControlDB\Contracts\Models\Group, maybe add an additional type check? ( Ignorable by Annotation )

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

46
            $settings = $this->positionSettingRetrieval->getSettings(/** @scrutinizer ignore-type */ $this->group());
Loading history...
47
        } catch (\Exception $e) {
48
            return false;
49
        }
50 7
        if(in_array($value, $settings['only_one_user'])) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
51 2
            return $this->roleRepository->getById($value)->users()->count() === 0;
52
        }
53 5
        return true;
54
    }
55
56 7
    protected function group()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function group()
Loading history...
57
    {
58 7
        return $this->authentication->getGroup();
59
    }
60
61
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
62
     * @inheritDoc
63
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
64 1
    public function message()
65
    {
66 1
        return 'A user is already assigned to this role';
67
    }
68
}