From 0fbb374507c12878ae05b70484e45a530c586792 Mon Sep 17 00:00:00 2001 From: Netkas Date: Thu, 15 Dec 2022 00:54:38 -0500 Subject: [PATCH] Added method \ncc\Runtime > Constants > get() https://git.n64.cc/nosial/ncc/-/issues/33 --- src/ncc/Runtime/Constants.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ncc/Runtime/Constants.php b/src/ncc/Runtime/Constants.php index 312b443..62e3eeb 100644 --- a/src/ncc/Runtime/Constants.php +++ b/src/ncc/Runtime/Constants.php @@ -68,4 +68,24 @@ unset(self::$Constants[$constant_hash]); } + + /** + * Gets the constant + * + * @param string $scope + * @param string $name + * @return string|null + */ + public static function get(string $scope, string $name): ?string + { + if(!Validate::constantName($name)) + return null; + + $constant_hash = Resolver::resolveConstantHash($scope, $name); + + if(isset(self::$Constants[$constant_hash])) + return self::$Constants[$constant_hash]->getValue(); + + return null; + } } \ No newline at end of file