diff --git a/src/FieldResolution/DefaultStrategy.php b/src/FieldResolution/DefaultStrategy.php index 26505655..51378dd2 100644 --- a/src/FieldResolution/DefaultStrategy.php +++ b/src/FieldResolution/DefaultStrategy.php @@ -21,7 +21,7 @@ /** * @internal */ -final class DefaultStrategy implements ResolutionStrategy +final class DefaultStrategy implements FieldValueResolutionStrategy, ResolutionStrategy { public function resolveFieldValue( Generator $faker, diff --git a/src/FieldResolution/FieldValueResolutionStrategy.php b/src/FieldResolution/FieldValueResolutionStrategy.php new file mode 100644 index 00000000..379d93ee --- /dev/null +++ b/src/FieldResolution/FieldValueResolutionStrategy.php @@ -0,0 +1,33 @@ +fieldValueResolutionStrategy = new FieldResolution\DefaultStrategy(); $this->resolutionStrategy = new FieldResolution\DefaultStrategy(); } @@ -239,7 +241,7 @@ public function createOne( ); $fieldValues = \array_map(function (FieldDefinition\Resolvable $fieldDefinition) { - return $this->resolutionStrategy->resolveFieldValue( + return $this->fieldValueResolutionStrategy->resolveFieldValue( $this->faker, $this, $fieldDefinition, @@ -325,6 +327,7 @@ public function withOptional(): self { $instance = clone $this; + $instance->fieldValueResolutionStrategy = new FieldResolution\WithOptionalStrategy(); $instance->resolutionStrategy = new FieldResolution\WithOptionalStrategy(); return $instance; @@ -342,6 +345,7 @@ public function withoutOptional(): self { $instance = clone $this; + $instance->fieldValueResolutionStrategy = new FieldResolution\WithoutOptionalStrategy(); $instance->resolutionStrategy = new FieldResolution\WithoutOptionalStrategy(); return $instance;