Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
MockableFeatures | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
mock | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
resolveMockedInstance | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
clearMockedInstances | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Hyde\Framework\Concerns\Internal; |
6 | |
7 | use Illuminate\Support\Str; |
8 | |
9 | /** |
10 | * Allows the Features class to be mocked. |
11 | * |
12 | * @internal This trait is not covered by the backward compatibility promise. |
13 | * |
14 | * @see \Hyde\Facades\Features |
15 | */ |
16 | trait MockableFeatures |
17 | { |
18 | protected static array $mockedInstances = []; |
19 | |
20 | public static function mock(string $feature, bool $enabled): void |
21 | { |
22 | static::$mockedInstances[Str::studly($feature)] = $enabled; |
23 | } |
24 | |
25 | public static function resolveMockedInstance(string $feature): ?bool |
26 | { |
27 | return static::$mockedInstances[Str::studly($feature)] ?? null; |
28 | } |
29 | |
30 | public static function clearMockedInstances(): void |
31 | { |
32 | static::$mockedInstances = []; |
33 | } |
34 | } |