ImportPackageCommand   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 17
dl 0
loc 52
ccs 17
cts 17
cp 1
rs 10
c 1
b 0
f 1
wmc 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B jsonSerialize() 0 29 9
A __construct() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\StandardCommand;
6
7
class ImportPackageCommand extends AbstractStandardCommand
8
{
9
    public const TYPE = 'ImportPackage';
10
11
    /**
12
     * @param string|null $accept Package accept property
13
     * @param string|null $name Package name property
14
     * @param AbstractStandardCommand[]|null $onFail Commands to run if import fails
15
     * @param AbstractStandardCommand[]|null $onLoad Commands to run when import loads
16
     * @param string|null $source Package source property
17
     * @param string|null $version Package version property
18
     */
19 6
    public function __construct(
20
        public ?string $accept = null,
21
        public ?string $name = null,
22
        public ?array $onFail = null,
23
        public ?array $onLoad = null,
24
        public ?string $source = null,
25
        public ?string $version = null,
26
    ) {
27 6
        parent::__construct(self::TYPE);
28
    }
29
30 4
    public function jsonSerialize(): array
31
    {
32 4
        $data = parent::jsonSerialize();
33
34 4
        if ($this->accept !== null) {
35 2
            $data['accept'] = $this->accept;
36
        }
37
38 4
        if ($this->name !== null) {
39 2
            $data['name'] = $this->name;
40
        }
41
42 4
        if ($this->onFail !== null && !empty($this->onFail)) {
43 1
            $data['onFail'] = $this->onFail;
44
        }
45
46 4
        if ($this->onLoad !== null && !empty($this->onLoad)) {
47 1
            $data['onLoad'] = $this->onLoad;
48
        }
49
50 4
        if ($this->source !== null) {
51 1
            $data['source'] = $this->source;
52
        }
53
54 4
        if ($this->version !== null) {
55 1
            $data['version'] = $this->version;
56
        }
57
58 4
        return $data;
59
    }
60
}
61