Geolocation   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 15
dl 0
loc 49
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromAmazonRequest() 0 12 6
1
<?php
2
3
namespace MaxBeckers\AmazonAlexa\Request;
4
5
/**
6
 * @author Brandon Olivares <[email protected]>
7
 */
8
class Geolocation
9
{
10
    /**
11
     * @var LocationServices|null
12
     */
13
    public $locationServices;
14
15
    /**
16
     * @var \DateTime
17
     */
18
    public $timestamp;
19
20
    /**
21
     * @var Coordinate|null
22
     */
23
    public $coordinate;
24
25
    /**
26
     * @var Altitude|null
27
     */
28
    public $altitude;
29
30
    /**
31
     * @var Heading|null
32
     */
33
    public $heading;
34
35
    /**
36
     * @var Speed|null
37
     */
38
    public $speed;
39
40
    /**
41
     * @param array $amazonRequest
42
     *
43
     * @return Geolocation
44
     */
45 1
    public static function fromAmazonRequest(array $amazonRequest): self
46
    {
47 1
        $geolocation = new self();
48
49 1
        $geolocation->locationServices = isset($amazonRequest['locationServices']) ? LocationServices::fromAmazonRequest($amazonRequest['locationServices']) : null;
50 1
        $geolocation->timestamp        = new \DateTime($amazonRequest['timestamp']);
51 1
        $geolocation->coordinate       = isset($amazonRequest['coordinate']) ? Coordinate::fromAmazonRequest($amazonRequest['coordinate']) : null;
52 1
        $geolocation->altitude         = isset($amazonRequest['altitude']) ? Altitude::fromAmazonRequest($amazonRequest['altitude']) : null;
53 1
        $geolocation->heading          = isset($amazonRequest['heading']) ? Heading::fromAmazonRequest($amazonRequest['heading']) : null;
54 1
        $geolocation->speed            = isset($amazonRequest['speed']) ? Speed::fromAmazonRequest($amazonRequest['speed']) : null;
55
56 1
        return $geolocation;
57
    }
58
}
59