Completed
Pull Request — develop (#326)
by
unknown
03:22
created

Location   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 27.45 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
c 0
b 0
f 0
lcom 0
cbo 2
dl 14
loc 51
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 12 12 5
A getLongitude() 0 4 1
A getLatitude() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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