-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
66 changed files
with
1,644 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\GraphQL\Builder\Enums; | ||
|
||
use GraphQL\Type\Definition\Deprecated; | ||
use GraphQL\Type\Definition\Description; | ||
|
||
enum Flag { | ||
case Yes; | ||
|
||
/** | ||
* @deprecated 5.4.0 Please use {@link Flag::Yes} instead. | ||
*/ | ||
#[Deprecated('Please use `Yes` instead.')] | ||
#[Description('')] | ||
case yes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/graphql/src/Builder/Traits/BuilderHelperFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\GraphQL\Builder\Traits; | ||
|
||
use Illuminate\Container\Container; | ||
|
||
use function array_key_exists; | ||
use function is_a; | ||
use function is_object; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
trait BuilderHelperFactory { | ||
/** | ||
* @var array<class-string, class-string> | ||
*/ | ||
private array $helpers = []; | ||
|
||
/** | ||
* @var array<class-string, class-string> | ||
*/ | ||
private array $classes = []; | ||
|
||
/** | ||
* @var array<class-string, ?object> | ||
*/ | ||
private array $instances = []; | ||
|
||
/** | ||
* @param class-string $builder | ||
* @param class-string $helper | ||
*/ | ||
private function addHelper(string $builder, string $helper): static { | ||
$this->helpers[$builder] = $helper; | ||
|
||
return $this; | ||
} | ||
|
||
private function getHelper(object $builder): ?object { | ||
if (!array_key_exists($builder::class, $this->instances)) { | ||
$class = $this->getHelperClass($builder::class); | ||
$this->instances[$builder::class] = $class | ||
? Container::getInstance()->make($class) | ||
: null; | ||
} | ||
|
||
return $this->instances[$builder::class]; | ||
} | ||
|
||
/** | ||
* @param object|class-string $builder | ||
* | ||
* @return ?class-string | ||
*/ | ||
private function getHelperClass(object|string $builder): ?string { | ||
if (is_object($builder)) { | ||
$builder = $builder::class; | ||
} | ||
|
||
if (!isset($this->classes[$builder])) { | ||
foreach ($this->helpers as $class => $sorter) { | ||
if (is_a($builder, $class, true)) { | ||
$this->classes[$builder] = $sorter; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return $this->classes[$builder]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.