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.

Issues (472)

app/Rules/UserIsAvailableToBeAssigned.php (25 issues)

1
<?php
2
0 ignored issues
show
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\AssignRoles\Rules;
4
5
use BristolSU\ControlDB\Contracts\Models\Role;
6
use BristolSU\ControlDB\Contracts\Repositories\User;
7
use BristolSU\Module\AssignRoles\Support\PositionSettingRetrieval;
8
use BristolSU\Support\Authentication\Contracts\Authentication;
9
use BristolSU\Support\Logic\Contracts\LogicRepository;
10
use BristolSU\Support\Logic\Facade\LogicTester;
11
use Illuminate\Contracts\Validation\Rule;
12
13
/**
14
 * Is the user available to be assigned?
15
 * 
16
 * If the user belongs to a user, which has a position that is 'user only has one user', they will not be available
17
 */
0 ignored issues
show
Missing @category tag in class comment
Loading history...
Missing @package tag in class comment
Loading history...
Missing @author tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
Missing @link tag in class comment
Loading history...
18
class UserIsAvailableToBeAssigned implements Rule
19
{
20
21
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
22
     * @var PositionSettingRetrieval
23
     */
24
    private $positionSettingRetrieval;
0 ignored issues
show
Private member variable "positionSettingRetrieval" must be prefixed with an underscore
Loading history...
25
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
26
     * @var Authentication
27
     */
28
    private $authentication;
0 ignored issues
show
Private member variable "authentication" must be prefixed with an underscore
Loading history...
29
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
30
     * @var User
31
     */
32
    private $userRepository;
0 ignored issues
show
Private member variable "userRepository" must be prefixed with an underscore
Loading history...
33
34 7
    public function __construct(Authentication $authentication, PositionSettingRetrieval $positionSettingRetrieval, User $userRepository)
0 ignored issues
show
Missing doc comment for function __construct()
Loading history...
35
    {
36 7
        $this->positionSettingRetrieval = $positionSettingRetrieval;
37 7
        $this->authentication = $authentication;
38 7
        $this->userRepository = $userRepository;
39 7
    }
40
41
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
Parameter $attribute should have a doc-comment as per coding-style.
Loading history...
Parameter $value should have a doc-comment as per coding-style.
Loading history...
42
     * @inheritDoc
43
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
44 7
    public function passes($attribute, $value)
45
    {
46
        try {
47 7
            $settings = $this->positionSettingRetrieval->getSettings($this->group());
0 ignored issues
show
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

47
            $settings = $this->positionSettingRetrieval->getSettings(/** @scrutinizer ignore-type */ $this->group());
Loading history...
48
        } catch (\Exception $e) {
49
            return false;
50
        }
51 7
        $user = $this->userRepository->getById($value);
52
53
        return $user->roles()->filter(function(Role $role) use ($settings, $user) {
0 ignored issues
show
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
The import $user is not used and could be removed.

This check looks for imports that have been defined, but are not used in the scope.

Loading history...
54 1
            return in_array($role->id(), $settings['user_only_has_one_role']);
55 7
        })->count() === 0;
0 ignored issues
show
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
56
    }
57
58 7
    protected function group()
0 ignored issues
show
Missing doc comment for function group()
Loading history...
59
    {
60 7
        return $this->authentication->getGroup();
61
    }
62
63
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
64
     * @inheritDoc
65
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
66 1
    public function message()
67
    {
68 1
        return 'The user is already in a role';
69
    }
70
}
71