Subcategories::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 5
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace JulianoBailao\DomusApi\Endpoints\Secondary;
4
5
use JulianoBailao\DomusApi\Contracts\GetContract;
6
use JulianoBailao\DomusApi\Core\Endpoint;
7
8 View Code Duplication
class Subcategories extends Endpoint implements GetContract
0 ignored issues
show
Duplication introduced by
This class 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...
9
{
10
    /**
11
     * The category id.
12
     *
13
     * @var int
14
     */
15
    protected $categoryId;
16
17
    /**
18
     * Create a new Subcategories instance.
19
     *
20
     * @param int $categoryId
21
     */
22 6
    public function __construct($client, $categoryId)
23
    {
24 6
        parent::__construct($client);
25 6
        $this->categoryId = $categoryId;
26 6
    }
27
28
    /**
29
     * Get a page of subcategories list.
30
     *
31
     * @param array $query the request query string.
32
     *
33
     * @return stdObject
34
     */
35 3
    public function paginate(array $query = [])
36
    {
37 3
        return $this->page('operacional/categorias/'.$this->categoryId.'/subcategorias', $query);
38
    }
39
40
    /**
41
     * Get a specific subcategory.
42
     *
43
     * @param int $id the subcategory id.
44
     *
45
     * @return stdObject
46
     */
47 3
    public function get($id)
48
    {
49 3
        return $this->run('GET', 'operacional/categorias/'.$this->categoryId.'/subcategorias/'.$id);
50
    }
51
}
52