-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62eeea7
commit fea0be6
Showing
15 changed files
with
822 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\DTO; | ||
|
||
final readonly class DefaultFeatureDependency implements FeatureDependency | ||
{ | ||
/** | ||
* @param array<Variant>|null $requiredVariants | ||
*/ | ||
public function __construct( | ||
private ?Feature $feature, | ||
private bool $expectedState, | ||
private ?array $requiredVariants, | ||
) { | ||
} | ||
|
||
public function getFeature(): ?Feature | ||
{ | ||
return $this->feature; | ||
} | ||
|
||
public function getExpectedState(): bool | ||
{ | ||
return $this->expectedState; | ||
} | ||
|
||
public function getRequiredVariants(): ?array | ||
{ | ||
return $this->requiredVariants; | ||
} | ||
|
||
public function isResolved(): bool | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\DTO; | ||
|
||
interface FeatureDependency | ||
{ | ||
public function getFeature(): ?Feature; | ||
|
||
public function getExpectedState(): bool; | ||
|
||
/** | ||
* @return array<Variant>|null | ||
*/ | ||
public function getRequiredVariants(): ?array; | ||
|
||
public function isResolved(): bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\DTO\Internal; | ||
|
||
use Unleash\Client\DTO\Feature; | ||
use Unleash\Client\DTO\FeatureDependency; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class UnresolvedFeature implements Feature | ||
{ | ||
public function __construct( | ||
private string $name, | ||
) { | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function isEnabled(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function getStrategies(): iterable | ||
{ | ||
return []; | ||
} | ||
|
||
public function getVariants(): array | ||
{ | ||
return []; | ||
} | ||
|
||
public function hasImpressionData(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* @return array<FeatureDependency> | ||
*/ | ||
public function getDependencies(): array | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\DTO\Internal; | ||
|
||
use Unleash\Client\DTO\Feature; | ||
use Unleash\Client\DTO\FeatureDependency; | ||
use Unleash\Client\DTO\Variant; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class UnresolvedFeatureDependency implements FeatureDependency | ||
{ | ||
/** | ||
* @param array<Variant>|null $requiredVariants | ||
*/ | ||
public function __construct( | ||
private Feature $feature, | ||
private bool $expectedState, | ||
private ?array $requiredVariants, | ||
) { | ||
} | ||
|
||
public function getFeature(): Feature | ||
{ | ||
return $this->feature; | ||
} | ||
|
||
public function getExpectedState(): bool | ||
{ | ||
return $this->expectedState; | ||
} | ||
|
||
public function getRequiredVariants(): ?array | ||
{ | ||
return $this->requiredVariants; | ||
} | ||
|
||
public function isResolved(): bool | ||
{ | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\DTO\Internal; | ||
|
||
use JetBrains\PhpStorm\ExpectedValues; | ||
use Unleash\Client\DTO\Variant; | ||
use Unleash\Client\DTO\VariantPayload; | ||
use Unleash\Client\Enum\Stickiness; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final readonly class UnresolvedVariant implements Variant | ||
{ | ||
public function __construct( | ||
private string $name, | ||
) { | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function isEnabled(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
public function getPayload(): ?VariantPayload | ||
{ | ||
return null; | ||
} | ||
|
||
public function getWeight(): int | ||
{ | ||
return 0; | ||
} | ||
|
||
public function getOverrides(): array | ||
{ | ||
return []; | ||
} | ||
|
||
#[ExpectedValues(valuesFromClass: Stickiness::class)] | ||
public function getStickiness(): string | ||
{ | ||
return Stickiness::DEFAULT; | ||
} | ||
|
||
/** | ||
* todo Change to null once rector supports it | ||
* | ||
* @return null | ||
* | ||
* @noinspection PhpMixedReturnTypeCanBeReducedInspection | ||
*/ | ||
public function jsonSerialize(): mixed | ||
{ | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.