Position::setData()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 4
c 1
b 0
f 0
nc 8
nop 3
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 4
rs 10
1
<?php
2
3
namespace kalanis\kw_coordinates\Support;
4
5
6
use kalanis\kw_coordinates\Interfaces\INumbers;
7
8
9
/**
10
 * Class Position
11
 * @package kalanis\kw_coordinates\Support
12
 * Transport values into other geographical system
13
 */
14
class Position implements INumbers
15
{
16
    /** @var float X  +-180° */
17
    protected float $longitude = 0.0;
18
    /** @var float Y +-90° */
19
    protected float $latitude = 0.0;
20
    /** @var float Z +-10000m */
21
    protected float $altitude = 0.0;
22
23 20
    public function setData(?float $longitude = 0.0, ?float $latitude = 0.0, ?float $altitude = 0.0): INumbers
24
    {
25 20
        $this->longitude = is_null($longitude) ? $this->longitude : $longitude;
26 20
        $this->latitude = is_null($latitude) ? $this->latitude : $latitude;
27 20
        $this->altitude = is_null($altitude) ? $this->altitude : $altitude;
28 20
        return $this;
29
    }
30
31 20
    public function getLongitude(): float
32
    {
33 20
        return $this->longitude;
34
    }
35
36 20
    public function getLatitude(): float
37
    {
38 20
        return $this->latitude;
39
    }
40
41 14
    public function getAltitude(): float
42
    {
43 14
        return $this->altitude;
44
    }
45
}
46