From fdc00301c09db97856773f048c71d5888156ff8f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 9 Jan 2024 10:35:14 +0800 Subject: [PATCH] add builder() and patch_point() global functions --- src/SPC/builder/BuilderProvider.php | 2 +- src/globals/functions.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index 23bcf6c5..d1e0cd77 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -43,7 +43,7 @@ class BuilderProvider /** * @throws WrongUsageException */ - public function getBuilder(): BuilderBase + public static function getBuilder(): BuilderBase { if (self::$builder === null) { throw new WrongUsageException('Builder has not been initialized'); diff --git a/src/globals/functions.php b/src/globals/functions.php index e48eaeeb..7b7540b3 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -3,6 +3,8 @@ declare(strict_types=1); use Psr\Log\LoggerInterface; +use SPC\builder\BuilderBase; +use SPC\builder\BuilderProvider; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\util\UnixShell; @@ -127,3 +129,23 @@ function cmd(?bool $debug = null): WindowsCmd { return new WindowsCmd($debug); } + +/** + * Get current builder. + * + * @throws WrongUsageException + */ +function builder(): BuilderBase +{ + return BuilderProvider::getBuilder(); +} + +/** + * Get current patch point. + * + * @throws WrongUsageException + */ +function patch_point(): string +{ + return BuilderProvider::getBuilder()->getPatchPoint(); +}