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 / License / Validate.php

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

130 lines 3.6 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\License;
4
5 use Give\Vendors\LiquidWeb\LicensingApiClient\Responses\Contracts\Response;
6 use Give\Vendors\LiquidWeb\LicensingApiClient\Responses\License\ValueObjects\LicenseSummary;
7
8 /**
9 * Represents the batch license validation response payload.
10 *
11 * @implements Response<array{
12 * license: array{license_key: string, status: string}|null,
13 * domain: string,
14 * is_production: bool,
15 * products: list<array{
16 * product_slug: string,
17 * status: string,
18 * is_valid: bool,
19 * entitlement: array{
20 * tier: string,
21 * site_limit: int,
22 * active_count: int,
23 * available: int,
24 * over_limit: bool,
25 * excess_activations: int,
26 * expiration_date: string,
27 * status: string,
28 * capabilities: list<string>
29 * }|null,
30 * activation: array{
31 * domain: string,
32 * activated_at: string
33 * }|null,
34 * available_entitlements: list<array{
35 * tier: string,
36 * site_limit: int,
37 * active_count: int,
38 * available: int,
39 * over_limit: bool,
40 * excess_activations: int,
41 * capabilities: list<string>,
42 * status: string,
43 * expires: string
44 * }>
45 * }>
46 * }>
47 */
48 final class Validate implements Response
49 {
50 public ?LicenseSummary $license;
51
52 public string $domain;
53
54 public bool $isProduction;
55
56 public ValidatedProductCollection $products;
57
58 /**
59 */
60 private function __construct(
61 ?LicenseSummary $license,
62 string $domain,
63 bool $isProduction,
64 ValidatedProductCollection $products
65 ) {
66 $this->license = $license;
67 $this->domain = $domain;
68 $this->isProduction = $isProduction;
69 $this->products = $products;
70 }
71
72 /**
73 * @param array{
74 * license: array{license_key: string, status: string}|null,
75 * domain: string,
76 * is_production: bool,
77 * products: list<array{
78 * product_slug: string,
79 * status: string,
80 * is_valid: bool,
81 * entitlement: array{
82 * tier: string,
83 * site_limit: int,
84 * active_count: int,
85 * available: int,
86 * over_limit: bool,
87 * excess_activations: int,
88 * expiration_date: string,
89 * status: string,
90 * capabilities: list<string>
91 * }|null,
92 * activation: array{
93 * domain: string,
94 * activated_at: string
95 * }|null,
96 * available_entitlements?: list<array{
97 * tier: string,
98 * site_limit: int,
99 * active_count: int,
100 * available: int,
101 * over_limit: bool,
102 * excess_activations: int,
103 * capabilities: list<string>,
104 * status: string,
105 * expires: string
106 * }>
107 * }>
108 * } $attributes
109 */
110 public static function from(array $attributes): self {
111 $license = $attributes['license'] ?? null;
112
113 return new self(
114 $license ? LicenseSummary::from($license) : null,
115 $attributes['domain'],
116 $attributes['is_production'],
117 ValidatedProductCollection::from($attributes['products'])
118 );
119 }
120
121 public function toArray(): array {
122 return [
123 'license' => $this->license ? $this->license->toArray() : null,
124 'domain' => $this->domain,
125 'is_production' => $this->isProduction,
126 'products' => $this->products->toArray(),
127 ];
128 }
129 }
130