give
/
vendor
/
vendor-prefixed
/
stellarwp
/
licensing-api-client
/
src
/
Responses
/
Credit
/
QuotaCollection.php
give
/
vendor
/
vendor-prefixed
/
stellarwp
/
licensing-api-client
/
src
/
Responses
/
Credit
Last commit date
ValueObjects
3 months ago
BalanceCollection.php
3 months ago
DeletePool.php
3 months ago
DeleteQuota.php
3 months ago
LedgerPage.php
3 months ago
PoolCollection.php
3 months ago
QuotaCollection.php
3 months ago
RecordUsage.php
3 months ago
Refund.php
3 months ago
QuotaCollection.php
79 lines
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Give\Vendors\LiquidWeb\LicensingApiClient\Responses\Credit; |
| 4 | |
| 5 | use Give\Vendors\LiquidWeb\LicensingApiClient\Responses\Contracts\Response; |
| 6 | use Give\Vendors\LiquidWeb\LicensingApiClient\Responses\Credit\ValueObjects\SiteQuota; |
| 7 | |
| 8 | /** |
| 9 | * Represents a collection of site quotas. |
| 10 | * |
| 11 | * @implements Response<array{ |
| 12 | * quotas: list<array{ |
| 13 | * domain: string, |
| 14 | * credit_type: string, |
| 15 | * quota: ?int, |
| 16 | * period: string, |
| 17 | * first_period_start: ?string, |
| 18 | * is_blocked: bool, |
| 19 | * is_uncapped: bool |
| 20 | * }> |
| 21 | * }> |
| 22 | */ |
| 23 | final class QuotaCollection implements Response |
| 24 | { |
| 25 | /** |
| 26 | * @var list<SiteQuota> |
| 27 | */ |
| 28 | public array $quotas; |
| 29 | |
| 30 | /** |
| 31 | * @param list<SiteQuota> $quotas |
| 32 | */ |
| 33 | private function __construct(array $quotas) { |
| 34 | $this->quotas = $quotas; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @param array{ |
| 39 | * quotas: list<array{ |
| 40 | * domain: string, |
| 41 | * credit_type: string, |
| 42 | * quota: ?int, |
| 43 | * period: string, |
| 44 | * first_period_start: ?string, |
| 45 | * is_blocked: bool, |
| 46 | * is_uncapped: bool |
| 47 | * }> |
| 48 | * } $attributes |
| 49 | */ |
| 50 | public static function from(array $attributes): self { |
| 51 | return new self(array_map( |
| 52 | static fn (array $quota): SiteQuota => SiteQuota::from($quota), |
| 53 | $attributes['quotas'] |
| 54 | )); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * @return array{ |
| 59 | * quotas: list<array{ |
| 60 | * domain: string, |
| 61 | * credit_type: string, |
| 62 | * quota: ?int, |
| 63 | * period: string, |
| 64 | * first_period_start: ?string, |
| 65 | * is_blocked: bool, |
| 66 | * is_uncapped: bool |
| 67 | * }> |
| 68 | * } |
| 69 | */ |
| 70 | public function toArray(): array { |
| 71 | return [ |
| 72 | 'quotas' => array_map( |
| 73 | static fn (SiteQuota $quota): array => $quota->toArray(), |
| 74 | $this->quotas |
| 75 | ), |
| 76 | ]; |
| 77 | } |
| 78 | } |
| 79 |