Passed
Push — master ( a53d55...43aca1 )
by Maximilian
03:50
created

Value::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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