Skip to content

Commit

Permalink
Added a new bucket to save the reason of a reject
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Oct 20, 2023
1 parent 4c63c1a commit c80cd14
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/RejectionWithReasonResultBucket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Kiboko\Component\Bucket;

use Kiboko\Contract\Bucket as Contract;

/**
* @template Type
*
* @implements Contract\RejectionResultBucketInterface<Type>
*/
final class RejectionWithReasonResultBucket implements Contract\RejectionResultBucketInterface
{
public function __construct(private mixed $value, private ?string $reason = null) {}

public function reject($value, $reason): self

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() has parameter $reason with no type specified.

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() has parameter $value with no type specified.

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() return type with generic class Kiboko\Component\Bucket\RejectionWithReasonResultBucket does not specify its types: Type

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() has parameter $reason with no type specified.

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() has parameter $value with no type specified.

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() return type with generic class Kiboko\Component\Bucket\RejectionWithReasonResultBucket does not specify its types: Type

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() has parameter $reason with no type specified.

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() has parameter $value with no type specified.

Check failure on line 18 in src/RejectionWithReasonResultBucket.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Bucket\RejectionWithReasonResultBucket::reject() return type with generic class Kiboko\Component\Bucket\RejectionWithReasonResultBucket does not specify its types: Type
{
$this->value = $value;
$this->reason = $reason;

return $this;
}

public function getReason(): ?string
{
return $this->reason;
}

/** @return iterable<Type> */
public function walkRejection(): iterable
{
return new \ArrayIterator([$this->value]);
}
}

0 comments on commit c80cd14

Please sign in to comment.