PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0.1 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 All 258 releases
give / vendor / vendor-prefixed / stellarwp / licensing-api-client / src / Resources / Concerns / RebindsAuthState.php

RebindsAuthState.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at vendor/vendor-prefixed/stellarwp/licensing-api-client/src/Resources/Concerns/RebindsAuthState.php

46 lines 1.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\Resources\Concerns;
4
5 use Give\Vendors\LiquidWeb\LicensingApiClient\Http\AuthState;
6 use Give\Vendors\LiquidWeb\LicensingApiClient\Resources\Credit\CreditsLedgerResource;
7 use Give\Vendors\LiquidWeb\LicensingApiClient\Resources\Credit\CreditsPoolsResource;
8 use Give\Vendors\LiquidWeb\LicensingApiClient\Resources\Credit\CreditsQuotasResource;
9 use Give\Vendors\LiquidWeb\LicensingApiClient\Resources\Credit\CreditsResource;
10 use Give\Vendors\LiquidWeb\LicensingApiClient\Resources\EntitlementsResource;
11 use Give\Vendors\LiquidWeb\LicensingApiClient\Resources\LicensesResource;
12 use Give\Vendors\LiquidWeb\LicensingApiClient\Resources\ProductsResource;
13 use Give\Vendors\LiquidWeb\LicensingApiClient\Resources\TokensResource;
14
15 /**
16 * Provides immutable auth-state rebinding for auth-bound resource views.
17 *
18 * @mixin CreditsLedgerResource
19 * @mixin CreditsPoolsResource
20 * @mixin CreditsQuotasResource
21 * @mixin CreditsResource
22 * @mixin EntitlementsResource
23 * @mixin LicensesResource
24 * @mixin ProductsResource
25 * @mixin TokensResource
26 */
27 trait RebindsAuthState
28 {
29 /**
30 * Returns the current resource when the auth state is unchanged, or a rebound
31 * resource view when a different auth state is requested.
32 */
33 public function withAuthState(AuthState $authState): self {
34 if ($this->authState === $authState) {
35 return $this;
36 }
37
38 return $this->rebindWithAuthState($authState);
39 }
40
41 /**
42 * Rebuilds the concrete resource with the provided auth state.
43 */
44 abstract protected function rebindWithAuthState(AuthState $authState): self;
45 }
46