-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStripePaymentMethodId.php
More file actions
43 lines (36 loc) · 1.15 KB
/
StripePaymentMethodId.php
File metadata and controls
43 lines (36 loc) · 1.15 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
34
35
36
37
38
39
40
41
42
43
<?php
namespace MatchBot\Domain;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Embeddable;
use MatchBot\Application\Assertion;
#[Embeddable]
readonly class StripePaymentMethodId
{
#[Column(type: 'string')]
public readonly string $stripePaymentMethodId;
private function __construct(
string $stripeCustomerId
) {
$this->stripePaymentMethodId = $stripeCustomerId;
Assertion::notEmpty($this->stripePaymentMethodId);
Assertion::maxLength($this->stripePaymentMethodId, 255);
Assertion::regex($this->stripePaymentMethodId, '/^pm_[a-zA-Z0-9]+$/'); // e.g. pm_df64s36cf
}
/**
* @param string $stripeID - must fit the pattern for a Stripe ID.
*/
public static function of(string $stripeID): self
{
return new self($stripeID);
}
/**
* @psalm-suppress PossiblyUnusedMethod - simple enough to keep even though not used right now.
*/
public function equals(StripePaymentMethodId|null $that): bool
{
if ($that === null) {
return false;
}
return $this->stripePaymentMethodId === $that->stripePaymentMethodId;
}
}