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

Value   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A jsonSerialize() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Response\Directives\APL\Document;
6
7
class Value implements \JsonSerializable
8
{
9
    /**
10
     * @param string $property The property to animate
11
     * @param int|float $to Target value for the animation
12
     * @param int|float|null $from Starting value (optional). Null means: use current runtime value as implicit start.
13
     */
14 13
    public function __construct(
15
        public string $property,
16
        public int|float $to,
17
        public int|float|null $from = null,
18
    ) {
19 13
    }
20
21 7
    public function jsonSerialize(): array
22
    {
23 7
        $out = [
24 7
            'property' => $this->property,
25 7
        ];
26
27 7
        if ($this->from !== null) {
28 5
            $out['from'] = $this->from;
29
        }
30
31 7
        $out['to'] = $this->to;
32
33 7
        return $out;
34
    }
35
}
36