Streets::save()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
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