3 declare(strict_types=1);
5 namespace CuyZ\Valinor\Mapper\Object\Factory;
7 use CuyZ\Valinor\Definition\ClassDefinition;
8 use CuyZ\Valinor\Mapper\Object\Exception\PermissiveTypeNotAllowed;
9 use CuyZ\Valinor\Utility\PermissiveTypeFound;
10 use CuyZ\Valinor\Utility\TypeHelper;
13 final class StrictTypesObjectBuilderFactory implements ObjectBuilderFactory
15 public function __construct(private ObjectBuilderFactory $delegate)
19 public function for(ClassDefinition $class): array
21 $builders = $this->delegate->for($class);
23 foreach ($builders as $builder) {
24 $arguments = $builder->describeArguments();
26 foreach ($arguments as $argument) {
28 TypeHelper::checkPermissiveType($argument->type());
29 } catch (PermissiveTypeFound $exception) {
30 throw new PermissiveTypeNotAllowed($builder, $argument, $exception);