Completed
Push — master ( c79f7e...463ede )
by Gallice
02:34
created

Location   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 53
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A getLatitude() 0 4 1
A getLongitude() 0 4 1
A jsonSerialize() 0 7 1
1
<?php
2
3
namespace Tgallice\Wit\Model;
4
5
class Location implements \JsonSerializable
6
{
7
    /**
8
     * @var float
9
     */
10
    private $latitude;
11
12
    /**
13
     * @var float
14
     */
15
    private $longitude;
16
17
    /**
18
     * @param float $latitude
19
     * @param float $longitude
20
     */
21 6
    public function __construct($latitude, $longitude)
22
    {
23 6
        if (empty($latitude) || empty($longitude)) {
24 2
            throw new \InvalidArgumentException('A latitude and longitude must be defined');
25
        }
26
27 4
        $this->latitude = (float) $latitude;
28 4
        $this->longitude = (float) $longitude;
29 4
    }
30
31
    /**
32
     * @return float
33
     */
34 1
    public function getLatitude()
35
    {
36 1
        return $this->latitude;
37
    }
38
39
    /**
40
     * @return float
41
     */
42 1
    public function getLongitude()
43
    {
44 1
        return $this->longitude;
45
    }
46
47
    /**
48
     * @return array
49
     */
50 1
    public function jsonSerialize()
51
    {
52
        return [
53 1
            'latitude' => $this->latitude,
54 1
            'longitude' => $this->longitude,
55 1
        ];
56
    }
57
}
58