Skip to content

Commit

Permalink
[minor] add Parameter::factory() helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Jan 9, 2021
1 parent e2dae5e commit d7f3ae0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Callback/Parameter.php
Expand Up @@ -27,6 +27,11 @@ final public static function untyped($value): self
return new UntypedParameter($value);
}

final public static function factory(callable $factory): ValueFactory
{
return new ValueFactory($factory);
}

/**
* @return mixed
*
Expand Down
3 changes: 1 addition & 2 deletions tests/CallbackTest.php
Expand Up @@ -6,7 +6,6 @@
use Zenstruck\Callback;
use Zenstruck\Callback\Exception\UnresolveableArgument;
use Zenstruck\Callback\Parameter;
use Zenstruck\Callback\ValueFactory;

/**
* @author Kevin Bond <kevinbond@gmail.com>
Expand Down Expand Up @@ -131,7 +130,7 @@ public function invoke_all_class_arguments_value_factories(): void
];
};
$factoryArgs = [];
$factory = new ValueFactory(static function($arg) use (&$factoryArgs) {
$factory = Parameter::factory(static function($arg) use (&$factoryArgs) {
$factoryArgs[] = $arg;

if ($arg) {
Expand Down

0 comments on commit d7f3ae0

Please sign in to comment.