1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Contract\Core; |
4: | |
5: | /** |
6: | * Has public constants with unique values of a given type, and maps them to and |
7: | * from their names |
8: | * |
9: | * @api |
10: | * |
11: | * @template TValue |
12: | * |
13: | * @extends EnumerationInterface<TValue> |
14: | */ |
15: | interface ConvertibleEnumerationInterface extends EnumerationInterface |
16: | { |
17: | /** |
18: | * Get the value of a public constant from its name |
19: | * |
20: | * @return TValue |
21: | */ |
22: | public static function fromName(string $name); |
23: | |
24: | /** |
25: | * Get the values of public constants from their names |
26: | * |
27: | * @param string[] $index |
28: | * @return TValue[] |
29: | */ |
30: | public static function fromNames(array $index): array; |
31: | |
32: | /** |
33: | * Get the name of a public constant from its value |
34: | * |
35: | * @param TValue $value |
36: | */ |
37: | public static function toName($value): string; |
38: | |
39: | /** |
40: | * Get the names of public constants from their values |
41: | * |
42: | * @param TValue[] $values |
43: | * @return string[] |
44: | */ |
45: | public static function toNames(array $values): array; |
46: | } |
47: |