Passed
Push — dev ( 80e888...e274b6 )
by Janko
07:22
created

JavascriptExecution   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 32
ccs 15
cts 15
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addExecuteJS() 0 10 1
A getExecuteJS() 0 8 2
A reset() 0 4 1
1
<?php
2
3
namespace Stu\Module\Control;
4
5
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Stu\Component\Game\JavascriptExecutionTypeEnum;
7
8
final class JavascriptExecution implements JavascriptExecutionInterface
9
{
10
    /** @var array<int, array<string>> */
11
    private static array $execjs = [];
12
13 214
    #[Override]
14
    public function getExecuteJS(JavascriptExecutionTypeEnum $when): ?array
15
    {
16 214
        if (!array_key_exists($when->value, self::$execjs)) {
17 211
            return null;
18
        }
19
20 23
        return self::$execjs[$when->value];
21
    }
22
23 23
    #[Override]
24
    public function addExecuteJS(string $value, JavascriptExecutionTypeEnum $when): void
25
    {
26 23
        match ($when) {
27 23
            JavascriptExecutionTypeEnum::BEFORE_RENDER =>
28 6
            self::$execjs[$when->value][] = $value,
29 23
            JavascriptExecutionTypeEnum::AFTER_RENDER =>
30 15
            self::$execjs[$when->value][] = $value,
31 23
            JavascriptExecutionTypeEnum::ON_AJAX_UPDATE =>
32 6
            self::$execjs[$when->value][] = $value
33 23
        };
34
    }
35
36 217
    #[Override]
37
    public static function reset(): void
38
    {
39 217
        self::$execjs = [];
40
    }
41
}
42