Passed
Push — master ( b464b5...fd08ce )
by Maximilian
45s queued 11s
created

Speed   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 7
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromAmazonRequest() 0 8 2
1
<?php
2
3
namespace MaxBeckers\AmazonAlexa\Request;
4
5
/**
6
 * @author Brandon Olivares <[email protected]>
7
 */
8
class Speed
9
{
10
    /**
11
     * @var float
12
     */
13
    public $speedInMetersPerSecond;
14
15
    /**
16
     * @var float|null
17
     */
18
    public $accuracyInMetersPerSecond;
19
20
    /**
21
     * @param array $amazonRequest
22
     *
23
     * @return Speed
24
     */
25
    public static function fromAmazonRequest(array $amazonRequest): self
26
    {
27
        $speed = new self();
28
29
        $speed->speedInMetersPerSecond      = floatval($amazonRequest['speedInMetersPerSecond']);
30
        $speed->accuracyInMetersPerSecond   = isset($amazonRequest['accuracyInMetersPerSecond']) ? floatval($amazonRequest['accuracyInMetersPerSecond']) : null;
31
32
        return $speed;
33
    }
34
}
35