-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial support for FlagMetadata in resolution
- Loading branch information
Showing
7 changed files
with
153 additions
and
5 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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenFeature\implementation\flags; | ||
|
||
use DateTime; | ||
use OpenFeature\implementation\common\ArrayHelper; | ||
use OpenFeature\interfaces\flags\FlagMetadata as FlagMetadataInterface; | ||
|
||
class FlagMetadata implements FlagMetadataInterface | ||
{ | ||
/** | ||
* @param Array<array-key, bool|string|int|float|DateTime|mixed[]|null> $attributesMap | ||
*/ | ||
public function __construct(protected array $metadata = []) | ||
{ | ||
} | ||
|
||
/** | ||
* Return key-type pairs of the attributes | ||
* | ||
* @return Array<int, string> | ||
*/ | ||
public function keys(): array | ||
{ | ||
return ArrayHelper::getStringKeys($this->metadata); | ||
} | ||
|
||
/** | ||
* @return bool|string|int|float|null | ||
*/ | ||
public function get(string $key): bool | string | int | float | null | ||
{ | ||
return $this->metadata[$key] ?? null; | ||
} | ||
|
||
/** | ||
* @return Array<array-key, bool|string|int|float|DateTime|mixed[]|null> | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return [...$this->metadata]; | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenFeature\interfaces\flags; | ||
|
||
use DateTime; | ||
|
||
/** | ||
* flag metadata MUST be a structure supporting the definition of arbitrary properties, | ||
* with keys of type string, and values of type boolean | string | number. | ||
*/ | ||
interface FlagMetadata | ||
{ | ||
/** | ||
* Return key-type pairs of the attributes | ||
* | ||
* @return Array<int, string> | ||
*/ | ||
public function keys(): array; | ||
|
||
/** | ||
* @return bool|string|int|float|null | ||
*/ | ||
public function get(string $key): bool | string | int | float | null; | ||
|
||
/** | ||
* @return Array<array-key, bool|string|int|float|null> | ||
*/ | ||
public function toArray(): 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