Total Complexity | 8 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | final class Config |
||
10 | { |
||
11 | /** |
||
12 | * Get an environment configuration value. |
||
13 | * |
||
14 | * Key existence and value type are validated. |
||
15 | */ |
||
16 | public static function bool(string $key): bool |
||
17 | { |
||
18 | $value = self::key($key); |
||
19 | if (!\is_bool($value)) { |
||
20 | throw new ConfigurationException(\sprintf('Value type for key "%s" is not valid', $key)); |
||
21 | } |
||
22 | return $value; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Get an environment configuration value. |
||
27 | * |
||
28 | * Key existence is validated. |
||
29 | * |
||
30 | * @return mixed |
||
31 | */ |
||
32 | public static function key(string $key) |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Get an environment configuration value. |
||
42 | * |
||
43 | * Key existence and value type are validated. |
||
44 | */ |
||
45 | public static function int(string $key): int |
||
46 | { |
||
47 | $value = self::key($key); |
||
48 | if (!\is_int($value)) { |
||
49 | throw new ConfigurationException(\sprintf('Value type for key "%s" is not valid', $key)); |
||
50 | } |
||
51 | return $value; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Get an environment configuration value. |
||
56 | * |
||
57 | * Key existence and value type are validated. |
||
58 | */ |
||
59 | public static function string(string $key): string |
||
66 | } |
||
67 | } |
||
68 |