Passed
Push — master ( 204e2b...dee98e )
by Gallice
03: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 0%

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 0
cts 23
cp 0
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
    public function __construct($latitude, $longitude)
22
    {
23
        if (empty($latitude) || empty($longitude)) {
24
            throw new \InvalidArgumentException('A latitude and longitude must be defined');
25
        }
26
27
        $this->latitude = (float) $latitude;
28
        $this->longitude = (float) $longitude;
29
    }
30
31
    /**
32
     * @return float
33
     */
34
    public function getLatitude()
35
    {
36
        return $this->latitude;
37
    }
38
39
    /**
40
     * @return float
41
     */
42
    public function getLongitude()
43
    {
44
        return $this->longitude;
45
    }
46
47
    /**
48
     * @return array
49
     */
50
    public function jsonSerialize()
51
    {
52
        return [
53
            'latitude' => $this->latitude,
54
            'longitude' => $this->longitude,
55
        ];
56
    }
57
}
58