Speed::fromAmazonRequest()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
c 1
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 Speed
11
{
12
    /**
13
     * @param float $speedInMetersPerSecond Speed in meters per second
14
     * @param float|null $accuracyInMetersPerSecond Accuracy of speed measurement in meters per second
15
     */
16 1
    public function __construct(
17
        public float $speedInMetersPerSecond,
18
        public ?float $accuracyInMetersPerSecond = null,
19
    ) {
20 1
    }
21
22 1
    public static function fromAmazonRequest(array $amazonRequest): self
23
    {
24 1
        return new self(
25 1
            speedInMetersPerSecond: (float) ($amazonRequest['speedInMetersPerSecond']),
26 1
            accuracyInMetersPerSecond: isset($amazonRequest['accuracyInMetersPerSecond']) ? (float) ($amazonRequest['accuracyInMetersPerSecond']) : null,
27 1
        );
28
    }
29
}
30