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.

OptionsSanitizingCapabilities::sanitizeOptions()   B
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 34
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 23
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 23
cts 23
cp 1
rs 8.439
c 0
b 0
f 0
cc 5
eloc 21
nc 5
nop 1
crap 5
1
<?php
2
3
/**
4
 * @license https://github.com/f500/swiftmailer-sparkpost/blob/master/LICENSE MIT
5
 */
6
7
namespace SwiftSparkPost;
8
9
/**
10
 * @copyright Future500 B.V.
11
 * @author    Jasper N. Brouwer <[email protected]>
12
 */
13
trait OptionsSanitizingCapabilities
14
{
15
    /**
16
     * @param array $options
17
     *
18
     * @return array
19
     * @throws Exception
20
     */
21 39
    private function sanitizeOptions(array $options)
22
    {
23
        $booleanOptions = [
24 39
            Option::TRANSACTIONAL,
25 39
            Option::OPEN_TRACKING,
26 39
            Option::CLICK_TRACKING,
27 39
            Option::SANDBOX,
28 39
            Option::SKIP_SUPPRESSION,
29 39
            Option::INLINE_CSS,
30 13
        ];
31
        $stringOptions  = [
32 39
            Option::IP_POOL,
33 13
        ];
34
35 39
        $sanitized = [];
36
37 39
        foreach ($options as $option => $value) {
38 39
            if (in_array($option, $stringOptions, true)) {
39 30
                if ($value) {
40 24
                    $sanitized[$option] = (string) $value;
41 8
                }
42 30
                continue;
43
            }
44
45 24
            if (in_array($option, $booleanOptions, true)) {
46 18
                $sanitized[$option] = (bool) $value;
47 18
                continue;
48
            }
49
50 6
            throw new Exception(sprintf('Unknown SparkPost option "%s"', $option));
51 11
        }
52
53 33
        return $sanitized;
54
    }
55
}
56