TrackedChange   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A fromAmazonRequest() 0 8 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Request;
6
7
class TrackedChange
8
{
9
    /**
10
     * @param string|null $uid Unique identifier
11
     * @param string|null $name Name of the tracked change
12
     * @param MediaState|null $from Previous media state
13
     * @param MediaState|null $to New media state
14
     * @param string|null $utcTime UTC timestamp of the change
15
     */
16 3
    public function __construct(
17
        public ?string $uid = null,
18
        public ?string $name = null,
19
        public ?MediaState $from = null,
20
        public ?MediaState $to = null,
21
        public ?string $utcTime = null,
22
    ) {
23 3
    }
24
25 3
    public static function fromAmazonRequest(array $amazonRequest): self
26
    {
27 3
        return new self(
28 3
            uid: $amazonRequest['uid'] ?? null,
29 3
            name: $amazonRequest['name'] ?? null,
30 3
            from: isset($amazonRequest['from']) ? MediaState::tryFrom($amazonRequest['from']) : null,
31 3
            to: isset($amazonRequest['to']) ? MediaState::tryFrom($amazonRequest['to']) : null,
32 3
            utcTime: $amazonRequest['utcTime'] ?? null,
33 3
        );
34
    }
35
}
36