Geolocation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 6
dl 0
loc 8
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MaxBeckers\AmazonAlexa\Request;
6
7
/**
8
 * @deprecated
9
 */
10
class Geolocation
11
{
12
    /**
13
     * @param LocationServices|null $locationServices Location services information
14
     * @param \DateTime $timestamp Timestamp of the geolocation data
15
     * @param Coordinate|null $coordinate Coordinate information
16
     * @param Altitude|null $altitude Altitude information
17
     * @param Heading|null $heading Heading information
18
     * @param Speed|null $speed Speed information
19
     */
20 1
    public function __construct(
21
        public ?LocationServices $locationServices = null,
22
        public \DateTime $timestamp = new \DateTime(),
23
        public ?Coordinate $coordinate = null,
24
        public ?Altitude $altitude = null,
25
        public ?Heading $heading = null,
26
        public ?Speed $speed = null,
27
    ) {
28 1
    }
29
30
    /**
31
     * @param array $amazonRequest
32
     *
33
     * @return Geolocation
34
     */
35 1
    public static function fromAmazonRequest(array $amazonRequest): self
36
    {
37 1
        return new self(
38 1
            locationServices: isset($amazonRequest['locationServices']) ? LocationServices::fromAmazonRequest($amazonRequest['locationServices']) : null,
39 1
            timestamp: new \DateTime($amazonRequest['timestamp']),
40 1
            coordinate: isset($amazonRequest['coordinate']) ? Coordinate::fromAmazonRequest($amazonRequest['coordinate']) : null,
41 1
            altitude: isset($amazonRequest['altitude']) ? Altitude::fromAmazonRequest($amazonRequest['altitude']) : null,
42 1
            heading: isset($amazonRequest['heading']) ? Heading::fromAmazonRequest($amazonRequest['heading']) : null,
43 1
            speed: isset($amazonRequest['speed']) ? Speed::fromAmazonRequest($amazonRequest['speed']) : null,
44 1
        );
45
    }
46
}
47