diff --git a/src/RejectionWithReasonResultBucket.php b/src/RejectionWithReasonResultBucket.php new file mode 100644 index 0000000..aedbf54 --- /dev/null +++ b/src/RejectionWithReasonResultBucket.php @@ -0,0 +1,36 @@ + + */ +final class RejectionWithReasonResultBucket implements Contract\RejectionResultBucketInterface +{ + public function __construct(private mixed $value, private ?string $reason = null) {} + + public function reject($value, $reason): self + { + $this->value = $value; + $this->reason = $reason; + + return $this; + } + + public function getReason(): ?string + { + return $this->reason; + } + + /** @return iterable */ + public function walkRejection(): iterable + { + return new \ArrayIterator([$this->value]); + } +}