1818use Constructo \Support \Reflective \Factory \Target ;
1919use Constructo \Support \Reflective \Notation ;
2020use Constructo \Support \Set ;
21+ use Constructo \Support \Value ;
2122use DateTime ;
2223use Faker \Factory ;
2324use Faker \Generator ;
@@ -247,28 +248,9 @@ private function resolveParameters(array $parameters, Set $presets): Set
247248 $ fromDefaultValue = $ this ->ignoreFromDefaultValue
248249 ? null
249250 : new FromDefaultValue ($ this ->notation , $ this ->formatters , $ this ->locale );
250- $ fromTypeAttributes = new FromTypeAttributes (
251- $ this ->notation ,
252- $ this ->formatters ,
253- $ this ->locale ,
254- $ this ->ignoreFromDefaultValue
255- );
256251 foreach ($ parameters as $ parameter ) {
257252 $ field = $ this ->casedField ($ parameter );
258- $ generated = (new FromDependency (
259- $ this ->notation ,
260- $ this ->formatters ,
261- $ this ->locale ,
262- $ this ->ignoreFromDefaultValue
263- ))
264- ->then (new FromTypeDate ($ this ->notation , $ this ->formatters , $ this ->locale ))
265- ->then (new FromCollection ($ this ->notation , $ this ->formatters , $ this ->locale ))
266- ->then (new FromTypeBuiltin ($ this ->notation , $ this ->formatters , $ this ->locale ))
267- ->then ($ fromTypeAttributes )
268- ->then (new FromEnum ($ this ->notation , $ this ->formatters , $ this ->locale ))
269- ->then ($ fromDefaultValue )
270- ->then (new FromPreset ($ this ->notation , $ this ->formatters , $ this ->locale ))
271- ->resolve ($ parameter , $ presets );
253+ $ generated = $ this ->generateValue ($ parameter , $ presets , $ fromDefaultValue );
272254
273255 if ($ generated === null ) {
274256 continue ;
@@ -288,4 +270,35 @@ private function locale(?string $locale): string
288270 };
289271 return $ locale ?? $ fallback ();
290272 }
273+
274+ /**
275+ * @throws ReflectionException
276+ */
277+ private function generateValue (
278+ ReflectionParameter $ parameter ,
279+ Set $ presets ,
280+ ?FromDefaultValue $ fromDefaultValue = null ,
281+ ): ?Value {
282+ return (new FromDependency (
283+ $ this ->notation ,
284+ $ this ->formatters ,
285+ $ this ->locale ,
286+ $ this ->ignoreFromDefaultValue
287+ ))
288+ ->then (new FromTypeDate ($ this ->notation , $ this ->formatters , $ this ->locale ))
289+ ->then (new FromCollection ($ this ->notation , $ this ->formatters , $ this ->locale ))
290+ ->then (new FromTypeBuiltin ($ this ->notation , $ this ->formatters , $ this ->locale ))
291+ ->then (
292+ new FromTypeAttributes (
293+ $ this ->notation ,
294+ $ this ->formatters ,
295+ $ this ->locale ,
296+ $ this ->ignoreFromDefaultValue
297+ )
298+ )
299+ ->then (new FromEnum ($ this ->notation , $ this ->formatters , $ this ->locale ))
300+ ->then ($ fromDefaultValue )
301+ ->then (new FromPreset ($ this ->notation , $ this ->formatters , $ this ->locale ))
302+ ->resolve ($ parameter , $ presets );
303+ }
291304}
0 commit comments