Completed
Push — master ( caad37...82c5ce )
by Dmitriy
06:13
created

PopularClient   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 95.74 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 2
c 2
b 1
f 1
lcom 1
cbo 3
dl 45
loc 47
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getModels() 10 10 1
A getCategoryModels() 9 10 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
 * 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 PopularClient
19
 *
20
 * @category Yandex
21
 * @package  MarketContent
22
 *
23
 * @author  Oleg Scherbakov <[email protected]>
24
 * @created 08.01.16 01:19
25
 */
26 View Code Duplication
class PopularClient extends ContentClient
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...
27
{
28
    /**
29
     * Get popular models
30
     *
31
     * Returns popular models of Yandex.Market service according to params.
32
     *
33
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/popular-docpage/
34
     *
35
     * @param array $params
36
     *
37
     * @return Models\ResponsePopularModelsGet
38
     */
39 1
    public function getModels($params = array())
40
    {
41 1
        $resource = 'popular.json';
42 1
        $resource .= '?' . $this->buildQueryString($params);
43 1
        $response = $this->getServiceResponse($resource);
44
45 1
        $getPopularModelsResponse = new Models\ResponsePopularModelsGet($response);
46
47 1
        return $getPopularModelsResponse;
48
    }
49
50
    /**
51
     * Get popular category models
52
     *
53
     * Returns popular category models of Yandex.Market service according to params.
54
     *
55
     * @see https://tech.yandex.ru/market/content-data/doc/dg/reference/popular-category-id-docpage/
56
     *
57
     * @param int   $categoryId
58
     * @param array $params
59
     *
60
     * @return Models\ResponsePopularCategoryModelsGet
61
     */
62 1
    public function getCategoryModels($categoryId, $params = array())
63
    {
64 1
        $resource = 'popular/' . $categoryId . '.json';
65 1
        $resource .= '?' . $this->buildQueryString($params);
66 1
        $response = $this->getServiceResponse($resource);
67
68 1
        $getPopularCategoryModelsResponse = new Models\ResponsePopularCategoryModelsGet($response);
69
70 1
        return $getPopularCategoryModelsResponse;
71
    }
72
}
73