Completed
Pull Request — master (#77)
by Matthias
05:09 queued 02:21
created

Options::getScanFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace ComposerRequireChecker\Cli;
4
5
class Options
6
{
7
    private $symbolWhitelist = [
8
        'null',
9
        'true',
10
        'false', // consts
11
        'static',
12
        'self',
13
        'parent', // class hierarchy
14
        'array',
15
        'string',
16
        'int',
17
        'float',
18
        'bool',
19
        'iterable',
20
        'callable',
21
        'void',
22
        'object' // types
23
    ];
24
25
    private $phpCoreExtensions = [
26
        "Core",
27
        "date",
28
        "pcre",
29
        "Phar",
30
        "Reflection",
31
        "SPL",
32
        "standard",
33
    ];
34
35
    private $scanFiles = [];
36
37
38 5
    public function __construct(array $options = [])
39
    {
40 5
        foreach ($options as $key => $option) {
41 4
            $methodName = 'set' . $this->getCamelCase($key);
42 4
            if (!method_exists($this, $methodName)) {
43 1
                throw new \InvalidArgumentException(
44 1
                    $key . ' is not a known option - there is no method ' . $methodName
45
                );
46
            }
47 3
            $this->$methodName($option);
48
        }
49 4
    }
50
51
    /**
52
     * @return array
53
     */
54 2
    public function getSymbolWhitelist(): array
55
    {
56 2
        return $this->symbolWhitelist;
57
    }
58
59
    /**
60
     * @return array
61
     */
62 2
    public function getPhpCoreExtensions(): array
63
    {
64 2
        return $this->phpCoreExtensions;
65
    }
66
67
    /**
68
     * @param array $symbolWhitelist
69
     */
70 2
    public function setSymbolWhitelist(array $symbolWhitelist)
71
    {
72 2
        $this->symbolWhitelist = $symbolWhitelist;
73 2
    }
74
75
    /**
76
     * @param array $phpCoreExtensions
77
     */
78 2
    public function setPhpCoreExtensions(array $phpCoreExtensions)
79
    {
80 2
        $this->phpCoreExtensions = $phpCoreExtensions;
81 2
    }
82
83
    /**
84
     * @return array
85
     */
86 1
    public function getScanFiles(): array
87
    {
88 1
        return $this->scanFiles;
89
    }
90
91
    /**
92
     * @param array $scanFiles
93
     */
94 1
    public function setScanFiles(array $scanFiles): void
95
    {
96 1
        $this->scanFiles = $scanFiles;
97 1
    }
98
99
    /**
100
     * @param string $string some-string
101
     * @return string someString
102
     */
103 4
    private function getCamelCase(string $string): string
104
    {
105 4
        return ucfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', $string))));
106
    }
107
}
108