-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAttributes.php
45 lines (38 loc) · 1.06 KB
/
Attributes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
declare(strict_types=1);
namespace OpenFeature\implementation\flags;
use DateTime;
use OpenFeature\implementation\common\ArrayHelper;
use OpenFeature\interfaces\flags\Attributes as AttributesInterface;
class Attributes implements AttributesInterface
{
/**
* @param array<array-key, bool|string|int|float|DateTime|mixed[]|null> $attributesMap
*/
public function __construct(protected array $attributesMap = [])
{
}
/**
* Return key-type pairs of the attributes
*
* @return array<int, string>
*/
public function keys(): array
{
return ArrayHelper::getStringKeys($this->attributesMap);
}
/**
* @return bool|string|int|float|DateTime|mixed[]|null
*/
public function get(string $key): bool | string | int | float | DateTime | array | null
{
return $this->attributesMap[$key] ?? null;
}
/**
* @return array<array-key, bool|string|int|float|DateTime|mixed[]|null>
*/
public function toArray(): array
{
return [...$this->attributesMap];
}
}