Total Complexity | 5 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
17 | final class Types |
||
18 | { |
||
19 | const ABSPATH = 1; |
||
20 | |||
21 | /** |
||
22 | * CLI input (e.g. -c <name>=<value>) verification |
||
23 | * |
||
24 | * @param string $value |
||
25 | * @param null|int $type |
||
26 | * |
||
27 | * @return null|string if input could not be verified, string otherwise |
||
28 | */ |
||
29 | 1 | public function verifyInput($value, $type) |
|
30 | { |
||
31 | 1 | switch ($type) { |
|
32 | case null: |
||
33 | 1 | return $value; |
|
34 | 1 | case self::ABSPATH: |
|
35 | 1 | return $this->verifyAbspath($value); |
|
36 | default: |
||
37 | 1 | throw new \LogicException(sprintf('not a type: %s', $type)); |
|
38 | } |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * verify a path is an absolute path without |
||
43 | * any dot and dot-dot parts. |
||
44 | * |
||
45 | * @param string $value |
||
46 | * |
||
47 | * @return null|string string if input $value is already the abspath, null otherwise |
||
48 | */ |
||
49 | 1 | public function verifyAbspath($value) |
|
54 | } |
||
55 | } |
||
56 |