Passed
Push — master ( 144d24...fed8db )
by Petr
02:14
created

Passing   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 28
ccs 13
cts 13
cp 1
rs 10
wmc 11

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toLonLat() 0 6 4
A fromLonLat() 0 6 4
A __construct() 0 4 3
1
<?php
2
3
namespace kalanis\kw_coordinates\Codecs;
4
5
6
use kalanis\kw_coordinates\Interfaces;
7
use kalanis\kw_coordinates\Support;
8
9
10
/**
11
 * Class Passing
12
 * @package kalanis\kw_coordinates\Codecs
13
 * Just pass through
14
 * Good when you convert between more codecs and one of them is the basic format
15
 */
16
class Passing implements Interfaces\ICodecs
17
{
18
    /** @var Interfaces\INumbers */
19
    protected $pos = null;
20
    /** @var Interfaces\IFormatted */
21
    protected $out = null;
22
23 8
    public function __construct(?Interfaces\INumbers $position = null, ?Interfaces\IFormatted $output = null)
24
    {
25 8
        $this->pos = $position ?: new Support\Position();
26 8
        $this->out = $output ?: new Support\DegreesObject();
27
    }
28
29 4
    public function fromLonLat(Interfaces\INumbers $position): Interfaces\IFormatted
30
    {
31 4
        return (clone $this->out)->setData(
32 4
            is_null($position->getLongitude()) ? null : strval($position->getLongitude()),
0 ignored issues
show
introduced by
The condition is_null($position->getLongitude()) is always false.
Loading history...
33 4
            is_null($position->getLatitude()) ? null : strval($position->getLatitude()),
0 ignored issues
show
introduced by
The condition is_null($position->getLatitude()) is always false.
Loading history...
34 4
            is_null($position->getAltitude()) ? null : strval($position->getAltitude()),
0 ignored issues
show
introduced by
The condition is_null($position->getAltitude()) is always false.
Loading history...
35
        );
36
    }
37
38 4
    public function toLonLat(Interfaces\IFormatted $source): Interfaces\INumbers
39
    {
40 4
        return (clone $this->pos)->setData(
41 4
            is_null($source->getLongitude()) ? null : floatval(strval($source->getLongitude())),
0 ignored issues
show
Bug introduced by
It seems like is_null($source->getLong...ource->getLongitude())) can also be of type null; however, parameter $longitude of kalanis\kw_coordinates\I...ces\INumbers::setData() does only seem to accept double, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

41
            /** @scrutinizer ignore-type */ is_null($source->getLongitude()) ? null : floatval(strval($source->getLongitude())),
Loading history...
42 4
            is_null($source->getLatitude()) ? null : floatval(strval($source->getLatitude())),
0 ignored issues
show
Bug introduced by
It seems like is_null($source->getLati...source->getLatitude())) can also be of type null; however, parameter $latitude of kalanis\kw_coordinates\I...ces\INumbers::setData() does only seem to accept double, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
            /** @scrutinizer ignore-type */ is_null($source->getLatitude()) ? null : floatval(strval($source->getLatitude())),
Loading history...
43 4
            is_null($source->getAltitude()) ? null : floatval(strval($source->getAltitude()))
0 ignored issues
show
Bug introduced by
It seems like is_null($source->getAlti...source->getAltitude())) can also be of type null; however, parameter $altitude of kalanis\kw_coordinates\I...ces\INumbers::setData() does only seem to accept double, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
            /** @scrutinizer ignore-type */ is_null($source->getAltitude()) ? null : floatval(strval($source->getAltitude()))
Loading history...
44
        );
45
    }
46
}
47