Passed
Pull Request — master (#97)
by Maximilian
03:52
created

Graphic   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 20
dl 0
loc 63
ccs 22
cts 22
cp 1
rs 10
c 1
b 0
f 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
A jsonSerialize() 0 21 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document;
6
7
use MaxBeckers\AmazonAlexa\Response\Directives\APL\AVGItem\AVGItem;
8
9
class Graphic implements \JsonSerializable
10
{
11
    /**
12
     * @param int $height Height of the graphic
13
     * @param int $width Width of the graphic
14
     * @param array|null $data Array of arbitrary data for inflation
15
     * @param string $description Description of the graphic
16
     * @param AVGItem|null $item Single AVG item to display
17
     * @param AVGItem[]|null $items Array of AVG items to display
18
     * @param string|null $lang Language of the graphic
19
     * @param LayoutDirection $layoutDirection Direction for rendering
20
     * @param Parameter[] $parameters Array of AVG parameters
21
     * @param array $resources Array of local graphic-specific resources
22
     * @param ScaleType $scaleTypeHeight How to scale height
23
     * @param ScaleType $scaleTypeWidth How to scale width
24
     * @param Style[] $styles Array of styles
25
     * @param string $type Type of graphic (must be "AVG")
26
     * @param string $version Version of AVG specification
27
     * @param int|null $viewportHeight Viewport height
28
     * @param int|null $viewportWidth Viewport width
29
     */
30 11
    public function __construct(
31
        public int $height,
32
        public int $width,
33
        public ?array $data = null,
34
        public string $description = '',
35
        public ?AVGItem $item = null,
36
        public ?array $items = null,
37
        public ?string $lang = null,
38
        public LayoutDirection $layoutDirection = LayoutDirection::LTR,
39
        public array $parameters = [],
40
        public array $resources = [],
41
        public ScaleType $scaleTypeHeight = ScaleType::NONE,
42
        public ScaleType $scaleTypeWidth = ScaleType::NONE,
43
        public array $styles = [],
44
        public string $type = 'AVG',
45
        public string $version = '1.2',
46
        public ?int $viewportHeight = null,
47
        public ?int $viewportWidth = null,
48
    ) {
49 11
    }
50
51 7
    public function jsonSerialize(): array
52
    {
53 7
        return array_filter([
54 7
            'data' => $this->data,
55 7
            'description' => $this->description,
56 7
            'height' => $this->height,
57 7
            'item' => $this->item,
58 7
            'items' => $this->items,
59 7
            'lang' => $this->lang,
60 7
            'layoutDirection' => $this->layoutDirection,
61 7
            'parameters' => $this->parameters,
62 7
            'resources' => $this->resources,
63 7
            'scaleTypeHeight' => $this->scaleTypeHeight,
64 7
            'scaleTypeWidth' => $this->scaleTypeWidth,
65 7
            'styles' => $this->styles,
66 7
            'type' => $this->type,
67 7
            'version' => $this->version,
68 7
            'viewportHeight' => $this->viewportHeight,
69 7
            'viewportWidth' => $this->viewportWidth,
70 7
            'width' => $this->width,
71 7
        ], fn ($value) => $value !== null && $value !== []);
72
    }
73
}
74