Completed
Push — master ( a6a531...660335 )
by Tobias
10:31
created

Coordinates::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Model;
14
15
use Geocoder\Assert;
16
17
/**
18
 * @author William Durand <[email protected]>
19
 */
20
final class Coordinates
21
{
22
    /**
23
     * @var float
24
     */
25
    private $latitude;
26
27
    /**
28
     * @var float
29
     */
30
    private $longitude;
31
32
    /**
33
     * @param float $latitude
34
     * @param float $longitude
35
     */
36 17
    public function __construct($latitude, $longitude)
37
    {
38 17
        Assert::notNull($latitude);
39 17
        Assert::notNull($longitude);
40
41 17
        $latitude = (float) $latitude;
42 17
        $longitude = (float) $longitude;
43
44 17
        Assert::latitude($latitude);
45 17
        Assert::longitude($longitude);
46
47 17
        $this->latitude = $latitude;
48 17
        $this->longitude = $longitude;
49 17
    }
50
51
    /**
52
     * Returns the latitude.
53
     *
54
     * @return float
55
     */
56 14
    public function getLatitude(): float
57
    {
58 14
        return $this->latitude;
59
    }
60
61
    /**
62
     * Returns the longitude.
63
     *
64
     * @return float
65
     */
66 14
    public function getLongitude(): float
67
    {
68 14
        return $this->longitude;
69
    }
70
71
    /**
72
     * Returns the coordinates as a tuple
73
     *
74
     * @return array
75
     */
76
    public function toArray(): array
77
    {
78
        return [$this->getLongitude(), $this->getLatitude()];
79
    }
80
}
81