-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDonationSequenceNumber.php
More file actions
33 lines (28 loc) · 1 KB
/
DonationSequenceNumber.php
File metadata and controls
33 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace MatchBot\Domain;
use MatchBot\Application\Assertion;
/**
* Used for a donation given as part of a regular giving mandate. May not be duplicated within one mandate, and
* indicates the date the donation should be taken, e.g. #1 indicates the donation taken at time of mandate creation,
* #2, will be taken one month (or possibly other regular period) later, #3 will be taken two months later etc.
*
* @psalm-suppress PossiblyUnusedProperty - to be used soon.
*/
readonly class DonationSequenceNumber
{
private function __construct(
public int $number
) {
// having a mandate last for 100 years is ambitious, putting some upper limit in mostly because its better
// than no limit, and it could catch a bug.
Assertion::between($number, 1, 12 * 100);
}
public static function of(int $number): DonationSequenceNumber
{
return new self($number);
}
public function next(): self
{
return new self($this->number + 1);
}
}