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

JavascriptExecution::addExecuteJS()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 10
ccs 8
cts 8
cp 1
crap 1
rs 10
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