Passed
Push — deprecate/crawlerapi ( 17ac42...77891c )
by Tomas Norre
04:15
created

removeDisallowedConfigurations()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 5.024

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 5
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 11
ccs 6
cts 10
cp 0.6
crap 5.024
rs 10
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
class ConfigurationService
23
{
24 3
    public static function removeDisallowedConfigurations(array $allowedConfigurations, array $configurations): array
25
    {
26 3
        if (count($allowedConfigurations) > 0) {
27
            // 	remove configuration that does not match the current selection
28 1
            foreach ($configurations as $confKey => $confArray) {
29 1
                if (! in_array($confKey, $allowedConfigurations, true)) {
30 1
                    unset($configurations[$confKey]);
31
                }
32
            }
33
        }
34 3
        return $configurations;
35
    }
36
}
37