PlaybackStartedRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 35
ccs 15
cts 15
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromAmazonRequest() 0 8 1
A __construct() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Request\Request\AudioPlayer;
6
7
use MaxBeckers\AmazonAlexa\Helper\PropertyHelper;
8
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest;
9
10
class PlaybackStartedRequest extends AudioPlayerRequest
11
{
12
    public const TYPE = 'AudioPlayer.PlaybackStarted';
13
14
    /**
15
     * @param \DateTime|null $timestamp Request timestamp
16
     * @param string|null $token Audio player token
17
     * @param string|null $requestId Request identifier
18
     * @param string|null $locale Request locale
19
     * @param int|null $offsetInMilliseconds Playback offset in milliseconds
20
     */
21 1
    public function __construct(
22
        ?\DateTime $timestamp = null,
23
        ?string $token = null,
24
        ?string $requestId = null,
25
        ?string $locale = null,
26
        public ?int $offsetInMilliseconds = null,
27
    ) {
28 1
        parent::__construct(
29 1
            type: self::TYPE,
30 1
            timestamp: $timestamp,
31 1
            token: $token,
32 1
            requestId: $requestId,
33 1
            locale: $locale
34 1
        );
35
    }
36
37 1
    public static function fromAmazonRequest(array $amazonRequest): AbstractRequest
38
    {
39 1
        return new self(
40 1
            timestamp: self::getTime(PropertyHelper::checkNullValueStringOrInt($amazonRequest, 'timestamp')),
41 1
            token: PropertyHelper::checkNullValueString($amazonRequest, 'token'),
42 1
            requestId: PropertyHelper::checkNullValueString($amazonRequest, 'requestId'),
43 1
            locale: PropertyHelper::checkNullValueString($amazonRequest, 'locale'),
44 1
            offsetInMilliseconds: PropertyHelper::checkNullValueInt($amazonRequest, 'offsetInMilliseconds'),
45 1
        );
46
    }
47
}
48