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

UserEventRequest::validateTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
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\Request\Request\APL;
6
7
use MaxBeckers\AmazonAlexa\Helper\PropertyHelper;
8
use MaxBeckers\AmazonAlexa\Request\Request\AbstractRequest;
9
10
class UserEventRequest extends AbstractRequest
11
{
12
    public const TYPE = 'Alexa.Presentation.APL.UserEvent';
13
14
    /**
15
     * @param string|null $token Token provided with the RenderDocument or ExecuteCommands directive
16
     * @param array $arguments Array of values specified in the arguments property of the SendEvent command
17
     * @param array|null $source Information about the APL component and event handler that was the source of this event
18
     * @param array|null $components Value of each component identified in the components property of the SendEvent command
19
     * @param string|null $presentationUri Generated token that identifies the widget (applies to widgets)
20
     */
21 2
    public function __construct(
22
        public ?string $token = null,
23
        public array $arguments = [],
24
        public ?array $source = null,
25
        public ?array $components = null,
26
        public ?string $presentationUri = null,
27
    ) {
28 2
        parent::__construct(type: self::TYPE);
29
    }
30
31 2
    public static function fromAmazonRequest(array $amazonRequest): AbstractRequest
32
    {
33 2
        return new self(
34 2
            token: PropertyHelper::checkNullValueString($amazonRequest, 'token'),
35 2
            arguments: $amazonRequest['arguments'] ?? [],
36 2
            source: $amazonRequest['source'] ?? null,
37 2
            components: $amazonRequest['components'] ?? null,
38 2
            presentationUri: PropertyHelper::checkNullValueString($amazonRequest, 'presentationUri'),
39 2
        );
40
    }
41
42 1
    public function validateTimestamp(): bool
43
    {
44 1
        return false;
45
    }
46
}
47