PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / vendor / vendor-prefixed / stellarwp / licensing-api-client / src / Responses / Credit / BalanceCollection.php

BalanceCollection.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at vendor/vendor-prefixed/stellarwp/licensing-api-client/src/Responses/Credit/BalanceCollection.php

92 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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\BalanceEntry;
7
8 /**
9 * Represents the credit balance response across one or more credit types.
10 *
11 * @implements Response<array{
12 * credits: list<array{
13 * credit_type: string,
14 * remaining: int,
15 * site_quota: int|null,
16 * site_used: int,
17 * site_remaining: int,
18 * aggregate_total: int,
19 * aggregate_used: int,
20 * aggregate_remaining: int,
21 * aggregate_overage: int,
22 * pools: list<array{
23 * pool_id: int,
24 * pool_remaining: int,
25 * priority: int,
26 * period: string,
27 * resets_on: string|null,
28 * expires_at: string|null,
29 * credits_total?: int,
30 * credits_used?: int,
31 * overage?: int,
32 * overage_limit?: int|null
33 * }>
34 * }>
35 * }>
36 */
37 final class BalanceCollection implements Response
38 {
39 /** @var list<BalanceEntry> */
40 public array $credits;
41
42 /**
43 * @param list<BalanceEntry> $credits
44 */
45 private function __construct(array $credits) {
46 $this->credits = $credits;
47 }
48
49 /**
50 * @param array{
51 * credits: list<array{
52 * credit_type: string,
53 * remaining: int,
54 * site_quota: int|null,
55 * site_used: int,
56 * site_remaining: int,
57 * aggregate_total: int,
58 * aggregate_used: int,
59 * aggregate_remaining: int,
60 * aggregate_overage: int,
61 * pools: list<array{
62 * pool_id: int,
63 * pool_remaining: int,
64 * priority: int,
65 * period: string,
66 * resets_on: string|null,
67 * expires_at: string|null,
68 * credits_total?: int,
69 * credits_used?: int,
70 * overage?: int,
71 * overage_limit?: int|null
72 * }>
73 * }>
74 * } $attributes
75 */
76 public static function from(array $attributes): self {
77 return new self(array_map(
78 static fn (array $credit): BalanceEntry => BalanceEntry::from($credit),
79 $attributes['credits']
80 ));
81 }
82
83 public function toArray(): array {
84 return [
85 'credits' => array_map(
86 static fn (BalanceEntry $credit): array => $credit->toArray(),
87 $this->credits
88 ),
89 ];
90 }
91 }
92