PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.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 All 257 releases
give / vendor / vendor-prefixed / stellarwp / licensing-api-client / src / Responses / Entitlement / Upsert.php

Upsert.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at vendor/vendor-prefixed/stellarwp/licensing-api-client/src/Responses/Entitlement/Upsert.php

58 lines 1.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\Entitlement;
4
5 use Give\Vendors\LiquidWeb\LicensingApiClient\Responses\Contracts\Response;
6 use Give\Vendors\LiquidWeb\LicensingApiClient\Responses\Entitlement\ValueObjects\UpsertProduct;
7
8 /**
9 * Represents an entitlement upsert response payload.
10 *
11 * @phpstan-import-type ResponseProductPayload from UpsertProduct
12 *
13 * @implements Response<array{
14 * license_key: string,
15 * products: list<ResponseProductPayload>
16 * }>
17 */
18 final class Upsert implements Response
19 {
20 public string $licenseKey;
21
22 /**
23 * @var UpsertProduct[]
24 */
25 public array $products;
26
27 /**
28 * @param UpsertProduct[] $products
29 */
30 private function __construct(string $licenseKey, array $products) {
31 $this->licenseKey = $licenseKey;
32 $this->products = $products;
33 }
34
35 /**
36 * @param array{license_key: string, products: list<ResponseProductPayload>} $attributes
37 */
38 public static function from(array $attributes): self {
39 return new self(
40 $attributes['license_key'],
41 array_map(
42 static fn (array $product): UpsertProduct => UpsertProduct::from($product),
43 $attributes['products']
44 )
45 );
46 }
47
48 public function toArray(): array {
49 return [
50 'license_key' => $this->licenseKey,
51 'products' => array_map(
52 static fn (UpsertProduct $product): array => $product->toArray(),
53 $this->products
54 ),
55 ];
56 }
57 }
58