Passed
Pull Request — master (#97)
by Maximilian
04:17
created

Gradient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A jsonSerialize() 0 14 3
A __construct() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document;
6
7
class Gradient implements \JsonSerializable
8
{
9
    /**
10
     * @param string[] $colorRange Array of colors for the gradient
11
     * @param string $description Description of the gradient
12
     * @param BackgroundType $type Type of gradient (linear or radial)
13
     * @param float[]|null $inputRange Array of input range values
14
     * @param int $angle Angle for linear gradients
15
     */
16 11
    public function __construct(
17
        public array $colorRange,
18
        public string $description = '',
19
        public BackgroundType $type = BackgroundType::LINEAR,
20
        public ?array $inputRange = [],
21
        public int $angle = 0,
22
    ) {
23 11
    }
24
25 7
    public function jsonSerialize(): array
26
    {
27 7
        $data = [
28 7
            'description' => $this->description,
29 7
            'colorRange' => $this->colorRange,
30 7
            'angle' => $this->angle,
31 7
            'type' => $this->type,
32 7
        ];
33
34 7
        if ($this->inputRange !== null && count($this->inputRange) > 0) {
35 3
            $data['inputRange'] = $this->inputRange;
36
        }
37
38 7
        return $data;
39
    }
40
}
41