Passed
Push — refactor/hadGroupAccess ( c4f21e...44d6ac )
by Tomas Norre
05:28
created

UserService::hasGroupAccess()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 6
nc 4
nop 2
dl 0
loc 11
ccs 7
cts 7
cp 1
crap 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AOE\Crawler\Service;
6
7
/*
8
 * (c) 2020 AOE GmbH <[email protected]>
9
 *
10
 * This file is part of the TYPO3 Crawler Extension.
11
 *
12
 * It is free software; you can redistribute it and/or modify it under
13
 * the terms of the GNU General Public License, either version 2
14
 * of the License, or any later version.
15
 *
16
 * For the full copyright and license information, please read the
17
 * LICENSE.txt file that was distributed with this source code.
18
 *
19
 * The TYPO3 project - inspiring people to share!
20
 */
21
22
use TYPO3\CMS\Core\Utility\GeneralUtility;
23
24
class UserService
25
{
26 3
    public static function hasGroupAccess(string $groupList, string $accessList): bool
27
    {
28 3
        if (empty($accessList)) {
29 1
            return true;
30
        }
31 2
        foreach (explode(',', $groupList) as $groupUid) {
32 2
            if (GeneralUtility::inList($accessList, $groupUid)) {
33 1
                return true;
34
            }
35
        }
36 1
        return false;
37
    }
38
}
39