give
/
vendor
/
vendor-prefixed
/
stellarwp
/
licensing-api-client
/
src
/
Responses
/
ValueObjects
/
PaginationLinks.php
give
/
vendor
/
vendor-prefixed
/
stellarwp
/
licensing-api-client
/
src
/
Responses
/
ValueObjects
Last commit date
CapabilityCollection.php
3 months ago
PageMeta.php
3 months ago
PaginationLinks.php
3 months ago
PaginationLinks.php
66 lines
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Give\Vendors\LiquidWeb\LicensingApiClient\Responses\ValueObjects; |
| 4 | |
| 5 | use Give\Vendors\LiquidWeb\LicensingApiClient\Responses\Contracts\Response; |
| 6 | |
| 7 | /** |
| 8 | * @implements Response<array{ |
| 9 | * first: string, |
| 10 | * last: string|null, |
| 11 | * prev: string|null, |
| 12 | * next: string|null |
| 13 | * }> |
| 14 | */ |
| 15 | final class PaginationLinks implements Response |
| 16 | { |
| 17 | public string $first; |
| 18 | |
| 19 | public ?string $last; |
| 20 | |
| 21 | public ?string $prev; |
| 22 | |
| 23 | public ?string $next; |
| 24 | |
| 25 | private function __construct(string $first, ?string $last, ?string $prev, ?string $next) { |
| 26 | $this->first = $first; |
| 27 | $this->last = $last; |
| 28 | $this->prev = $prev; |
| 29 | $this->next = $next; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @param array{ |
| 34 | * first: string, |
| 35 | * last: string|null, |
| 36 | * prev: string|null, |
| 37 | * next: string|null |
| 38 | * } $attributes |
| 39 | */ |
| 40 | public static function from(array $attributes): self { |
| 41 | return new self( |
| 42 | $attributes['first'], |
| 43 | $attributes['last'], |
| 44 | $attributes['prev'], |
| 45 | $attributes['next'] |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @return array{ |
| 51 | * first: string, |
| 52 | * last: string|null, |
| 53 | * prev: string|null, |
| 54 | * next: string|null |
| 55 | * } |
| 56 | */ |
| 57 | public function toArray(): array { |
| 58 | return [ |
| 59 | 'first' => $this->first, |
| 60 | 'last' => $this->last, |
| 61 | 'prev' => $this->prev, |
| 62 | 'next' => $this->next, |
| 63 | ]; |
| 64 | } |
| 65 | } |
| 66 |