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.

SiteAccessGroupVoter::vote()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
cc 4
nc 4
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\Bundle\SiteAccessRoutesBundle\Matcher\Voter;
6
7
use function in_array;
8
9
final class SiteAccessGroupVoter implements VoterInterface
10
{
11
    /**
12
     * @var array
13
     */
14
    private $groupsBySiteAccess;
15
16
    public function __construct(array $groupsBySiteAccess)
17
    {
18
        $this->groupsBySiteAccess = $groupsBySiteAccess;
19
    }
20
21
    /**
22
     * Returns if provided siteaccess is allowed based on passed route config.
23
     */
24
    public function vote(string $siteAccess, array $routeConfig): ?bool
25
    {
26
        // We skip the check if siteaccess is not part of any group
27
        if (!isset($this->groupsBySiteAccess[$siteAccess])) {
28
            return VoterInterface::ABSTAIN;
29
        }
30
31
        // We allow the siteaccess if any group to which the siteaccess belongs
32
        // is in the list of allowed siteaccesses
33
        foreach ($this->groupsBySiteAccess[$siteAccess] as $group) {
34
            if (in_array($group, $routeConfig, true)) {
35
                return true;
36
            }
37
        }
38
39
        return VoterInterface::ABSTAIN;
40
    }
41
}
42