Completed
Pull Request — develop (#326)
by
unknown
04:31
created

Location::getLongitude()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Entities;
12
13
use Longman\TelegramBot\Exception\TelegramException;
14
15
class Location extends Entity
16
{
17
    /**
18
     * @var mixed|null
19
     */
20
    protected $longitude;
21
22
    /**
23
     * @var mixed|null
24
     */
25
    protected $latitude;
26
27
    /**
28
     * Location constructor.
29
     *
30
     * @param array $data
31
     * @throws \Longman\TelegramBot\Exception\TelegramException
32
     */
33 5 View Code Duplication
    public function __construct(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35 5
        $this->longitude = isset($data['longitude']) ? $data['longitude'] : null;
36 5
        if (empty($this->longitude)) {
37 1
            throw new TelegramException('longitude is empty!');
38
        }
39
40 4
        $this->latitude = isset($data['latitude']) ? $data['latitude'] : null;
41 4
        if (empty($this->latitude)) {
42 1
            throw new TelegramException('latitude is empty!');
43
        }
44 3
    }
45
46
    /**
47
     * Get longitude
48
     *
49
     * @return mixed|null
50
     */
51 1
    public function getLongitude()
52
    {
53 1
        return $this->longitude;
54
    }
55
56
    /**
57
     * Get latitude
58
     *
59
     * @return mixed|null
60
     */
61 1
    public function getLatitude()
62
    {
63 1
        return $this->latitude;
64
    }
65
}
66