AuthenticationData.php
2 years ago
DonateControllerData.php
1 year ago
DonateFormRouteData.php
1 year ago
DonateRouteData.php
2 years ago
DonationConfirmationReceiptViewRouteData.php
2 years ago
DonationFormGoalData.php
2 years ago
DonationFormPreviewRouteData.php
2 years ago
DonationFormQueryData.php
2 years ago
DonationFormViewRouteData.php
2 years ago
LegacyPurchaseFormData.php
2 years ago
UserData.php
2 years ago
ValidationRouteData.php
2 years ago
DonationConfirmationReceiptViewRouteData.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonationForms\DataTransferObjects; |
| 4 | |
| 5 | use function strlen; |
| 6 | |
| 7 | /** |
| 8 | * @since 3.0.0 |
| 9 | */ |
| 10 | class DonationConfirmationReceiptViewRouteData |
| 11 | { |
| 12 | /** |
| 13 | * @var string|null |
| 14 | */ |
| 15 | public $receiptId; |
| 16 | |
| 17 | /** |
| 18 | * |
| 19 | * @since 3.0.0 |
| 20 | */ |
| 21 | public static function fromRequest(array $request): self |
| 22 | { |
| 23 | $self = new self(); |
| 24 | |
| 25 | $self->receiptId = isset($request['receipt-id']) && $self::isReceiptIdValid( |
| 26 | $request['receipt-id'] |
| 27 | ) ? $request['receipt-id'] : null; |
| 28 | |
| 29 | return $self; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * The receipt ID is a md5 hash which has a 32 character length. |
| 34 | * |
| 35 | * @since 3.0.0 |
| 36 | */ |
| 37 | public static function isReceiptIdValid(string $receiptId): bool |
| 38 | { |
| 39 | return strlen($receiptId) === 32; |
| 40 | } |
| 41 | } |
| 42 |