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/Support/RequiredSettingRetrieval.php (13 issues)

1
<?php
2
0 ignored issues
show
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\AssignRoles\Support;
4
5
use BristolSU\ControlDB\Contracts\Models\Group;
6
use BristolSU\ControlDB\Contracts\Repositories\Position;
7
use BristolSU\Support\Logic\Contracts\Audience\LogicAudience;
8
use BristolSU\Support\Logic\Contracts\LogicRepository;
9
use BristolSU\Support\Logic\Facade\LogicTester;
10
use BristolSU\Support\ModuleInstance\ModuleInstance;
11
use Illuminate\Support\Facades\Cache;
12
13
class RequiredSettingRetrieval
0 ignored issues
show
Missing doc comment for class RequiredSettingRetrieval
Loading history...
14
{
15
16
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
17
     * @var LogicRepository
18
     */
19
    private $logicRepository;
0 ignored issues
show
Private member variable "logicRepository" must be prefixed with an underscore
Loading history...
20
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
21
     * @var LogicAudience
22
     */
23
    private $logicAudience;
0 ignored issues
show
Private member variable "logicAudience" must be prefixed with an underscore
Loading history...
24
    /**
0 ignored issues
show
Missing short description in doc comment
Loading history...
25
     * @var Position
26
     */
27
    private $positionRepository;
0 ignored issues
show
Private member variable "positionRepository" must be prefixed with an underscore
Loading history...
28
29
    public function __construct(LogicRepository $logicRepository, LogicAudience $logicAudience, Position $positionRepository)
0 ignored issues
show
Missing doc comment for function __construct()
Loading history...
30
    {
31
        $this->logicRepository = $logicRepository;
32
        $this->logicAudience = $logicAudience;
33
        $this->positionRepository = $positionRepository;
34
    }
35
36
    public function getSettings(Group $group, array $settings, ModuleInstance $moduleInstance)
0 ignored issues
show
Missing doc comment for function getSettings()
Loading history...
37
    {
38
        if(Cache::has($this->getCacheKey($group, $moduleInstance))) {
0 ignored issues
show
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
39
            return Cache::get($this->getCacheKey($group, $moduleInstance));
40
        }
41
        foreach ((array_key_exists('required', $settings)?$settings['required']:[]) as $setting) {
42
            if ($this->groupIsForSetting($group, $setting)) {
43
                Cache::put($this->getCacheKey($group, $moduleInstance), $setting['required'], 7200);
44
                return $setting['required'];
45
            }
46
        }
47
        throw new SettingRetrievalException('Could not find a setting');
48
    }
49
50
    protected function getCacheKey(Group $group, ModuleInstance $moduleInstance)
0 ignored issues
show
Missing doc comment for function getCacheKey()
Loading history...
51
    {
52
        return RequiredSettingRetrieval::class . '.' . $moduleInstance->id() . '.' . $group->id();
53
    }
54
    
55
    protected function groupIsForSetting(Group $group, array $setting): bool
0 ignored issues
show
Missing doc comment for function groupIsForSetting()
Loading history...
56
    {
57
        if (!array_key_exists('logic_id', $setting)) {
58
            return false;
59
        }
60
        $logic = $this->logicRepository->getById($setting['logic_id']);
61
        return LogicTester::evaluate($logic, null, $group, null);
62
    }
63
64
}