Skip to content

Commit

Permalink
Remove unnecessary check in ContainerAttributeResolverFactory (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Oct 25, 2023
1 parent 0429b31 commit 4460cf7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ interface AttributeResolverFactoryInterface
/**
* @throws AttributeResolverNonInstantiableException
*/
public function create(DataAttributeInterface|ParameterAttributeInterface $attribute): object;
public function create(DataAttributeInterface|ParameterAttributeInterface $attribute): mixed;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

namespace Yiisoft\Hydrator\AttributeHandling\ResolverFactory;

use LogicException;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Yiisoft\Hydrator\Attribute\Data\DataAttributeInterface;
use Yiisoft\Hydrator\AttributeHandling\Exception\AttributeResolverNonInstantiableException;
use Yiisoft\Hydrator\Attribute\Parameter\ParameterAttributeInterface;

use function is_object;
use function is_string;

final class ContainerAttributeResolverFactory implements AttributeResolverFactoryInterface
Expand All @@ -27,7 +25,7 @@ public function __construct(
/**
* @throws ContainerExceptionInterface
*/
public function create(DataAttributeInterface|ParameterAttributeInterface $attribute): object
public function create(DataAttributeInterface|ParameterAttributeInterface $attribute): mixed
{
$resolver = $attribute->getResolver();
if (!is_string($resolver)) {
Expand All @@ -43,18 +41,6 @@ public function create(DataAttributeInterface|ParameterAttributeInterface $attri
);
}

$result = $this->container->get($resolver);

if (!is_object($result)) {
throw new LogicException(
sprintf(
'Resolver "%s" must be an object, "%s" given.',
$resolver,
get_debug_type($result),
),
);
}

return $result;
return $this->container->get($resolver);
}
}

0 comments on commit 4460cf7

Please sign in to comment.