Total Complexity | 5 |
Total Lines | 44 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class ApplicationUtils |
||
10 | { |
||
11 | /** |
||
12 | * @param string[] $required list of required extension names |
||
13 | * |
||
14 | * @return bool True if the check is successful. |
||
15 | * |
||
16 | * @throws MissingRequirementException |
||
17 | */ |
||
18 | public static function checkExtensionRequirements(array $required): bool |
||
19 | { |
||
20 | foreach ($required as $extension) { |
||
21 | if (! extension_loaded($extension)) { |
||
22 | throw new MissingRequirementException(sprintf( |
||
23 | 'PHP extension php-%s is required and must be loaded', |
||
24 | $extension |
||
25 | )); |
||
26 | } |
||
27 | } |
||
28 | |||
29 | return true; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Checks the PHP version to ensure WT can run |
||
34 | * |
||
35 | * @param string $minVersion minimum PHP required version |
||
36 | * @param string $curVersion current PHP version (use PHP_VERSION) |
||
37 | * |
||
38 | * @return bool True if the check is successful. |
||
39 | * |
||
40 | * @throws MissingRequirementException |
||
41 | */ |
||
42 | public static function checkPHPVersion(string $minVersion, string $curVersion): bool |
||
53 | } |
||
54 | } |
||
55 |