-
Notifications
You must be signed in to change notification settings - Fork 12
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
Showing
13 changed files
with
327 additions
and
49 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,52 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\DTO; | ||
|
||
use JetBrains\PhpStorm\ArrayShape; | ||
|
||
final class DefaultDepencency implements Dependency | ||
{ | ||
/** | ||
* @param array<string> $variants | ||
*/ | ||
public function __construct( | ||
private readonly string $feature, | ||
private readonly ?bool $enabled, | ||
private readonly ?array $variants = null, | ||
) { | ||
} | ||
|
||
/** | ||
* @phpstan-return array<string|bool|array<string>> | ||
*/ | ||
#[ArrayShape(['name' => 'string', 'enabled' => 'bool', 'variants' => 'array'])] | ||
public function jsonSerialize(): array | ||
{ | ||
$result = [ | ||
'name' => $this->feature, | ||
]; | ||
if ($this->enabled !== null) { | ||
$result['enabled'] = $this->enabled; | ||
} | ||
if ($this->variants !== null) { | ||
$result['variants'] = $this->variants; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
public function getFeature(): string | ||
{ | ||
return $this->feature; | ||
} | ||
|
||
public function getEnabled(): ?bool | ||
{ | ||
return $this->enabled; | ||
} | ||
|
||
public function getVariants(): ?array | ||
{ | ||
return $this->variants; | ||
} | ||
} |
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; | ||
|
||
use JsonSerializable; | ||
|
||
interface Dependency extends JsonSerializable | ||
{ | ||
public function getFeature(): string; | ||
|
||
public function getEnabled(): ?bool; | ||
|
||
/** | ||
* @return array<string> | ||
*/ | ||
public function getVariants(): ?array; | ||
} |
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
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,27 @@ | ||
<?php | ||
|
||
namespace Unleash\Client\Event; | ||
|
||
use Unleash\Client\Configuration\Context; | ||
|
||
final class FeatureToggleDependencyNotFoundEvent extends AbstractEvent | ||
{ | ||
/** | ||
* @internal | ||
*/ | ||
public function __construct( | ||
private readonly Context $context, | ||
private readonly string $featureName, | ||
) { | ||
} | ||
|
||
public function getContext(): Context | ||
{ | ||
return $this->context; | ||
} | ||
|
||
public function getFeatureName(): string | ||
{ | ||
return $this->featureName; | ||
} | ||
} |
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.