mirror of
https://github.com/n3w/helpers-cli-input.git
synced 2025-12-19 12:43:23 +00:00
Updated InputHandlerFactory and InputTypeFactory to work with changes in pointybeard/helpers-foundation-factory 1.0.2
This commit is contained in:
parent
46b87d3d62
commit
e542f6fd94
2 changed files with 15 additions and 10 deletions
|
|
@ -9,27 +9,34 @@ use pointybeard\Helpers\Foundation\Factory;
|
|||
|
||||
final class InputHandlerFactory extends Factory\AbstractFactory
|
||||
{
|
||||
public static function getTemplateNamespace(): string
|
||||
public function getTemplateNamespace(): string
|
||||
{
|
||||
return __NAMESPACE__.'\\Handlers\\%s';
|
||||
}
|
||||
|
||||
public static function getExpectedClassType(): ?string
|
||||
public function getExpectedClassType(): ?string
|
||||
{
|
||||
return __NAMESPACE__.'\\Interfaces\\InputHandlerInterface';
|
||||
}
|
||||
|
||||
public static function build(string $name, InputCollection $collection = null, int $flags = null): Interfaces\InputHandlerInterface
|
||||
public static function build(string $name, ...$arguments): object
|
||||
{
|
||||
|
||||
// Since passing flags is optional, we can use array_pad
|
||||
// to ensure there are always at least 2 elements in $arguments
|
||||
[$collection, $flags] = array_pad($arguments, 2, null);
|
||||
|
||||
$factory = new self;
|
||||
|
||||
try {
|
||||
$handler = self::instanciate(
|
||||
self::generateTargetClassName($name)
|
||||
$handler = $factory->instanciate(
|
||||
$factory->generateTargetClassName($name)
|
||||
);
|
||||
} catch (\Exception $ex) {
|
||||
throw new Exceptions\UnableToLoadInputHandlerException($name, 0, $ex);
|
||||
}
|
||||
|
||||
if ($collection instanceof InputCollection) {
|
||||
if (null !== $collection) {
|
||||
$handler->bind(
|
||||
$collection,
|
||||
$flags
|
||||
|
|
|
|||
|
|
@ -8,14 +8,12 @@ use pointybeard\Helpers\Foundation\Factory;
|
|||
|
||||
final class InputTypeFactory extends Factory\AbstractFactory
|
||||
{
|
||||
use Factory\Traits\hasSimpleFactoryBuildMethodTrait;
|
||||
|
||||
public static function getTemplateNamespace(): string
|
||||
public function getTemplateNamespace(): string
|
||||
{
|
||||
return __NAMESPACE__.'\\Types\\%s';
|
||||
}
|
||||
|
||||
public static function getExpectedClassType(): ?string
|
||||
public function getExpectedClassType(): ?string
|
||||
{
|
||||
return __NAMESPACE__.'\\Interfaces\\InputTypeInterface';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue