Passed
Push — master ( 0dc587...d0f7b8 )
by Maximilian
45s queued 10s
created

InputEvent   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 15
dl 0
loc 48
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromAmazonRequest() 0 11 1
1
<?php
2
3
namespace MaxBeckers\AmazonAlexa\Request\Request\GameEngine\Event;
4
5
/**
6
 * @author Fabian Graßl <[email protected]>
7
 */
8
class InputEvent
9
{
10
    const ACTION_DOWN = 'down';
11
    const ACTION_UP   = 'up';
12
13
    /**
14
     * @var string
15
     */
16
    public $gadgetId;
17
18
    /**
19
     * @var \DateTime
20
     */
21
    public $timestamp;
22
23
    /**
24
     * @var string
25
     */
26
    public $action;
27
28
    /**
29
     * @var string
30
     */
31
    public $color;
32
33
    /**
34
     * @var string
35
     */
36
    public $feature;
37
38
    /**
39
     * @param array $amazonRequest
40
     *
41
     * @throws \Exception
42
     *
43
     * @return InputEvent
44
     */
45
    public static function fromAmazonRequest(array $amazonRequest): self
46
    {
47
        $event = new self();
48
49
        $event->gadgetId   = $amazonRequest['gadgetId'];
50
        $event->timestamp  = new \DateTime($amazonRequest['timestamp']);
51
        $event->action     = $amazonRequest['action'];
52
        $event->color      = $amazonRequest['color'];
53
        $event->feature    = $amazonRequest['feature'];
54
55
        return $event;
56
    }
57
}
58