| Total Complexity | 5 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | trait MockableFeatures |
||
| 11 | { |
||
| 12 | protected static array $mockedInstances = []; |
||
| 13 | |||
| 14 | public static function mock(string|array $feature, ?bool $enabled = null): void |
||
| 15 | { |
||
| 16 | if (is_array($feature)) { |
||
|
|
|||
| 17 | foreach ($feature as $key => $value) { |
||
| 18 | static::mock($key, $value); |
||
| 19 | } |
||
| 20 | |||
| 21 | return; |
||
| 22 | } |
||
| 23 | |||
| 24 | static::$mockedInstances[$feature] = $enabled; |
||
| 25 | } |
||
| 26 | |||
| 27 | public static function resolveMockedInstance(string $feature): ?bool |
||
| 28 | { |
||
| 29 | return static::$mockedInstances[$feature] ?? null; |
||
| 30 | } |
||
| 31 | |||
| 32 | public static function clearMockedInstances(): void |
||
| 35 | } |
||
| 36 | } |
||
| 37 |