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 / Refund.php

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

80 lines 1.9 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
7 /**
8 * Represents a successful credit refund response.
9 *
10 * @implements Response<array{
11 * credits_refunded: int,
12 * pool_remaining: int,
13 * site_remaining: int|null,
14 * pool_breakdown: array<array-key, int>
15 * }>
16 */
17 final class Refund implements Response
18 {
19 public int $creditsRefunded;
20
21 public int $poolRemaining;
22
23 public ?int $siteRemaining;
24
25 /**
26 * @var array<int, int>
27 */
28 public array $poolBreakdown;
29
30 /**
31 * @param array<int, int> $poolBreakdown
32 */
33 private function __construct(int $creditsRefunded, int $poolRemaining, ?int $siteRemaining, array $poolBreakdown) {
34 $this->creditsRefunded = $creditsRefunded;
35 $this->poolRemaining = $poolRemaining;
36 $this->siteRemaining = $siteRemaining;
37 $this->poolBreakdown = $poolBreakdown;
38 }
39
40 /**
41 * @param array{
42 * credits_refunded: int,
43 * pool_remaining: int,
44 * site_remaining: int|null,
45 * pool_breakdown: array<array-key, int>
46 * } $attributes
47 */
48 public static function from(array $attributes): self {
49 $poolBreakdown = [];
50
51 foreach ($attributes['pool_breakdown'] as $poolId => $creditsRefunded) {
52 $poolBreakdown[(int) $poolId] = $creditsRefunded;
53 }
54
55 return new self(
56 $attributes['credits_refunded'],
57 $attributes['pool_remaining'],
58 $attributes['site_remaining'],
59 $poolBreakdown
60 );
61 }
62
63 /**
64 * @return array{
65 * credits_refunded: int,
66 * pool_remaining: int,
67 * site_remaining: int|null,
68 * pool_breakdown: array<int, int>
69 * }
70 */
71 public function toArray(): array {
72 return [
73 'credits_refunded' => $this->creditsRefunded,
74 'pool_remaining' => $this->poolRemaining,
75 'site_remaining' => $this->siteRemaining,
76 'pool_breakdown' => $this->poolBreakdown,
77 ];
78 }
79 }
80