From 3e8dfd7f6b2f3c4dc3a21a3726b4b30f3ab2add5 Mon Sep 17 00:00:00 2001 From: JakubKermes Date: Thu, 27 Jun 2024 12:19:16 +0200 Subject: [PATCH] add ContextHelper.php --- config/blt.php | 6 ++++++ src/Features/Traits/Dispatcher.php | 8 ++++---- ...{RecognizeClassHelper.php => ClassHelper.php} | 2 +- src/Helpers/ContextHelper.php | 16 ++++++++++++++++ 4 files changed, 27 insertions(+), 5 deletions(-) rename src/Helpers/{RecognizeClassHelper.php => ClassHelper.php} (98%) create mode 100644 src/Helpers/ContextHelper.php diff --git a/config/blt.php b/config/blt.php index c7bd6a7..2ed9235 100644 --- a/config/blt.php +++ b/config/blt.php @@ -7,4 +7,10 @@ "default" => "App\\", "types" => [], ], + "helpers" => [ + "array" => "Blumilk\BLT\Helpers\ArrayHelper", + "class" => "Blumilk\BLT\Helpers\ClassHelper", + "context" => "Blumilk\BLT\Helpers\ContextHelper", + "nullable" => "Blumilk\BLT\Helpers\NullableHelper", + ] ]; diff --git a/src/Features/Traits/Dispatcher.php b/src/Features/Traits/Dispatcher.php index ef55aa1..5742394 100644 --- a/src/Features/Traits/Dispatcher.php +++ b/src/Features/Traits/Dispatcher.php @@ -5,7 +5,7 @@ namespace Blumilk\BLT\Features\Traits; use Behat\Gherkin\Node\TableNode; -use Blumilk\BLT\Helpers\RecognizeClassHelper; +use Blumilk\BLT\Helpers\ClassHelper; use Blumilk\BLT\Helpers\TypesEnum; use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher; use Illuminate\Contracts\Container\BindingResolutionException; @@ -61,7 +61,7 @@ public function dispatchObject(string $objectName, ?TableNode $table = null, int } } - $objectClass = RecognizeClassHelper::recognizeObjectClass($objectName); + $objectClass = ClassHelper::recognizeObjectClass($objectName); $object = new $objectClass(...$parameters); @@ -80,14 +80,14 @@ public function dispatchObject(string $objectName, ?TableNode $table = null, int */ public function assertDispatched(string $objectName, int $count = 1): void { - $objectClass = RecognizeClassHelper::recognizeObjectClass($objectName); + $objectClass = ClassHelper::recognizeObjectClass($objectName); $this->resolveFaker($objectName)->assertDispatched($objectClass, $count); } protected function resolveFaker(string $objectName): BusFake|EventFake { - $objectType = RecognizeClassHelper::guessType($objectName); + $objectType = ClassHelper::guessType($objectName); return match ($objectType) { TypesEnum::Job->value => $this->busFake, diff --git a/src/Helpers/RecognizeClassHelper.php b/src/Helpers/ClassHelper.php similarity index 98% rename from src/Helpers/RecognizeClassHelper.php rename to src/Helpers/ClassHelper.php index 7bfc705..7463533 100644 --- a/src/Helpers/RecognizeClassHelper.php +++ b/src/Helpers/ClassHelper.php @@ -6,7 +6,7 @@ use Illuminate\Support\Str; -class RecognizeClassHelper +class ClassHelper { public static function recognizeObjectClass(string $objectName): string { diff --git a/src/Helpers/ContextHelper.php b/src/Helpers/ContextHelper.php new file mode 100644 index 0000000..515c783 --- /dev/null +++ b/src/Helpers/ContextHelper.php @@ -0,0 +1,16 @@ +