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

InputEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 5
dl 0
loc 7
ccs 0
cts 1
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Request\Request\GameEngine\Event;
6
7
class InputEvent
8
{
9
    public const ACTION_DOWN = 'down';
10
    public const ACTION_UP = 'up';
11
12
    /**
13
     * @param string $gadgetId Gadget identifier
14
     * @param \DateTime $timestamp Event timestamp
15
     * @param string $action Action type (down/up)
16
     * @param string $color Color of the input
17
     * @param string $feature Feature that triggered the event
18
     */
19
    public function __construct(
20
        public string $gadgetId,
21
        public \DateTime $timestamp,
22
        public string $action,
23
        public string $color,
24
        public string $feature,
25
    ) {
26
    }
27
28 1
    public static function fromAmazonRequest(array $amazonRequest): self
29
    {
30 1
        return new self(
31 1
            gadgetId: $amazonRequest['gadgetId'],
32 1
            timestamp: new \DateTime($amazonRequest['timestamp']),
33 1
            action: $amazonRequest['action'],
34 1
            color: $amazonRequest['color'],
35 1
            feature: $amazonRequest['feature'],
36 1
        );
37
    }
38
}
39