From 50d522dac633ba4feb5fb201d67d250b415836c5 Mon Sep 17 00:00:00 2001 From: Zi Xing Date: Sun, 17 Apr 2022 18:47:45 -0400 Subject: [PATCH] Added Runtime extensions checker --- src/ncc/Utilities/Validate.php | 35 ++++++++++++++++++++++++++++++ tests/utils/runtime_extensions.php | 5 +++++ 2 files changed, 40 insertions(+) create mode 100644 tests/utils/runtime_extensions.php diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index 8fa45f3..1ca050d 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -12,6 +12,41 @@ */ class Validate { + /** + * Determines if the runtime meets the required extensions + * + * @return array + */ + public static function requiredExtensions(): array + { + $requirements = [ + 'zlib', + 'libxml', + 'ctype', + 'json', + 'mbstring', + 'posix', + 'ctype', + 'tokenizer' + ]; + + $results = []; + + foreach($requirements as $ext) + { + if(in_array(strtolower($ext), get_loaded_extensions())) + { + $results[$ext] = true; + } + else + { + $results[$ext] = false; + } + } + + return $results; + } + /** * Validates the version number * diff --git a/tests/utils/runtime_extensions.php b/tests/utils/runtime_extensions.php new file mode 100644 index 0000000..f12006b --- /dev/null +++ b/tests/utils/runtime_extensions.php @@ -0,0 +1,5 @@ +