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

UserEventRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fromAmazonRequest() 0 8 1
A __construct() 0 8 1
A validateTimestamp() 0 3 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