Streets   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 84
Duplicated Lines 26.19 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 22
loc 84
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A paginate() 7 7 1
A get() 7 7 1
A create() 0 4 1
A save() 8 8 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
namespace JulianoBailao\DomusApi\Endpoints\Secondary;
4
5
use JulianoBailao\DomusApi\Contracts\GetContract;
6
use JulianoBailao\DomusApi\Core\DataReceiver;
7
use JulianoBailao\DomusApi\Core\Endpoint;
8
9
class Streets extends Endpoint implements GetContract
10
{
11
    /**
12
     * The city id.
13
     *
14
     * @var int
15
     */
16
    protected $cityId;
17
18
    /**
19
     * The neighborhood id.
20
     *
21
     * @var int
22
     */
23
    protected $neighborhoodId;
24
25
    /**
26
     * Create a new Models instance.
27
     *
28
     * @param int $neighborhoodId
29
     */
30 9
    public function __construct($client, $cityId, $neighborhoodId)
31
    {
32 9
        parent::__construct($client);
33 9
        $this->cityId = $cityId;
34 9
        $this->neighborhoodId = $neighborhoodId;
35 9
    }
36
37
    /**
38
     * Get a page of models list.
39
     *
40
     * @param array $query the request query string.
41
     *
42
     * @return stdObject
43
     */
44 3 View Code Duplication
    public function paginate(array $query = [])
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...
45
    {
46 3
        return $this->page(
47 3
            'operacional/enderecos/localidade/'.$this->cityId.'/bairros/'.$this->neighborhoodId.'/logradouro',
48
            $query
49 3
        );
50
    }
51
52
    /**
53
     * Get a specific model.
54
     *
55
     * @param int $id the model id.
56
     *
57
     * @return stdObject
58
     */
59 3 View Code Duplication
    public function get($id)
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...
60
    {
61 3
        return $this->run(
62 3
            'GET',
63 3
            'operacional/enderecos/localidade/'.$this->cityId.'/bairros/'.$this->neighborhoodId.'/logradouro/'.$id
64 3
        );
65
    }
66
67
    /**
68
     * Create a new neighborhood.
69
     *
70
     * @return DataReceiver
71
     */
72 3
    public function create()
73
    {
74 3
        return new DataReceiver($this);
75
    }
76
77
    /**
78
     * Send the save request.
79
     *
80
     * @param DataReceiver $data
81
     *
82
     * @return stdClass
83
     */
84 3 View Code Duplication
    public function save(DataReceiver $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...
85
    {
86 3
        return $this->run(
87 3
            'POST',
88 3
            'operacional/enderecos/localidade/'.$this->cityId.'/bairros/'.$this->neighborhoodId.'/logradouro',
89 3
            ['json' => $data->toArray()]
90 3
        );
91
    }
92
}
93