Completed
Pull Request — master (#139)
by
unknown
04:18
created

CategoryClient::getChildren()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4286
cc 1
eloc 6
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Yandex PHP Library
4
 *
5
 * @copyright NIX Solutions Ltd.
6
 * @link      https://github.com/nixsolutions/yandex-php-library
7
 */
8
9
/**
10
 * @namespace
11
 */
12
namespace Yandex\Market\Content\Clients;
13
14
use Yandex\Market\Content\ContentClient;
15
use Yandex\Market\Content\Models;
16
17
/**
18
 * Class CategoryClient
19
 *
20
 * @category Yandex
21
 * @package  MarketContent
22
 *
23
 * @author  Oleg Scherbakov <[email protected]>
24
 * @created 04.01.16 23:54
25
 */
26
class CategoryClient extends ContentClient
27
{
28
    /**
29
     * Get Categories
30
     *
31
     * Returns categories list of Yandex.Market service according to params.
32
     *
33
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/category-docpage/
34
     *
35
     * @param array $params
36
     *
37
     * @return Models\ResponseCategoryGetList
38
     */
39 1
    public function getList($params = array())
40
    {
41 1
        $resource = 'category.json';
42 1
        $resource .= '?' . $this->buildQueryString($params);
43 1
        $response = $this->getServiceResponse($resource);
44
45 1
        $getCategoriesResponse = new Models\ResponseCategoryGetList($response);
46
47 1
        return $getCategoriesResponse;
48
    }
49
50
    /**
51
     * Get category information
52
     *
53
     * Returns category of Yandex.Market service according to params.
54
     *
55
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/category-id-docpage/
56
     *
57
     * @param int   $categoryId
58
     * @param array $params
59
     *
60
     * @return Models\Category
61
     */
62 1 View Code Duplication
    public function get($categoryId, $params = array())
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...
63
    {
64 1
        $resource = 'category/' . $categoryId . '.json';
65 1
        $resource .= '?' . $this->buildQueryString($params);
66 1
        $response = $this->getServiceResponse($resource);
67
68 1
        $getCategoryResponse = new Models\ResponseCategoryGet($response);
69
70 1
        return $getCategoryResponse->getCategory();
71
    }
72
73
    /**
74
     * Get children categories
75
     *
76
     * Returns children categories list of Yandex.Market service according to params.
77
     *
78
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/category-id-children-docpage/
79
     *
80
     * @param int   $categoryId
81
     * @param array $params
82
     *
83
     * @return Models\ResponseCategoryGetList
84
     */
85 1
    public function getChildren($categoryId, $params = array())
86
    {
87 1
        $resource = 'category/' . $categoryId . '/children.json';
88 1
        $resource .= '?' . $this->buildQueryString($params);
89 1
        $response = $this->getServiceResponse($resource);
90
91 1
        $getCategoryResponse = new Models\ResponseCategoryGetList($response);
92
93 1
        return $getCategoryResponse;
94
    }
95
96
    /**
97
     * Get models in category
98
     *
99
     * Returns models list represented in category of Yandex.Market service according to params.
100
     *
101
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/category-id-model-docpage/
102
     *
103
     * @param int   $categoryId
104
     * @param array $params
105
     *
106
     * @return Models\ResponseCategoryGetModels
107
     */
108 1
    public function getModels($categoryId, $params = array())
109
    {
110 1
        $resource = 'category/' . $categoryId . '/models.json';
111 1
        $resource .= '?' . $this->buildQueryString($params);
112 1
        $response = $this->getServiceResponse($resource);
113
114 1
        $getCategoryModelsResponse = new Models\ResponseCategoryGetModels($response);
115
116 1
        return $getCategoryModelsResponse;
117
    }
118
119
    /**
120
     * Get filters in category
121
     *
122
     * Returns filters list of models represented in category of Yandex.Market service according to params.
123
     *
124
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/category-id-filters-docpage/
125
     *
126
     * @param int   $categoryId
127
     * @param array $params
128
     *
129
     * @return Models\ResponseCategoryGetFilters
130
     */
131 1
    public function getFilters($categoryId, $params = array())
132
    {
133 1
        $resource = 'category/' . $categoryId . '/filters.json';
134 1
        $resource .= '?' . $this->buildQueryString($params);
135 1
        $response = $this->getServiceResponse($resource);
136
137 1
        $getCategoryFiltersResponse = new Models\ResponseCategoryGetFilters($response);
138
139 1
        return $getCategoryFiltersResponse;
140
    }
141
}
142