Total Complexity | 8 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class StoryManager |
||
11 | { |
||
12 | /** @var array<string, Story> */ |
||
13 | private static array $globalInstances = []; |
||
14 | |||
15 | /** @var array<string, Story> */ |
||
16 | private static array $instances = []; |
||
17 | |||
18 | 38 | public static function has(string $story): bool |
|
19 | { |
||
20 | 38 | return \array_key_exists($story, self::$globalInstances) || \array_key_exists($story, self::$instances); |
|
21 | } |
||
22 | |||
23 | 4 | public static function get(string $story): Story |
|
24 | { |
||
25 | 4 | if (\array_key_exists($story, self::$globalInstances)) { |
|
26 | 2 | return self::$globalInstances[$story]; |
|
27 | } |
||
28 | |||
29 | 2 | return self::$instances[$story]; |
|
30 | } |
||
31 | |||
32 | 38 | public static function set(Story $story): void |
|
33 | { |
||
34 | 38 | self::$instances[\get_class($story)] = $story; |
|
35 | 38 | } |
|
36 | |||
37 | 38 | public static function setGlobalState(): void |
|
38 | { |
||
39 | 38 | self::$globalInstances = self::$instances; |
|
40 | 38 | self::$instances = []; |
|
41 | 38 | } |
|
42 | |||
43 | 38 | public static function reset(): void |
|
46 | 38 | } |
|
47 | |||
48 | 38 | public static function globalReset(): void |
|
51 | 38 | } |
|
52 | } |
||
53 |