Issue   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 22.03 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 13
loc 59
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getUrl() 13 13 2

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
 * Class Issue
4
 *
5
 * @author       Denis Shestakov <[email protected]>
6
 * @copyright    Copyright (c) 2017, Lan Publishing
7
 * @license      MIT
8
 */
9
10
namespace Lan\Ebs\Sdk\Model;
11
12
use Exception;
13
use Lan\Ebs\Sdk\Classes\Model;
14
use Lan\Ebs\Sdk\Client;
15
16
/**
17
 * Модель выпусков
18
 *
19
 * @property mixed name
20
 * @property mixed year
21
 * @property mixed url
22
 * @property mixed thumb
23
 *
24
 * @package      Lan\Ebs
25
 * @subpackage   Sdk
26
 * @category     Model
27
 */
28
class Issue extends Model
29
{
30
    /**
31
     * Номер выпуска
32
     */
33
    const FIELD_NAME = 'name';
34
35
    /**
36
     * Год выпуска
37
     */
38
    const FIELD_YEAR = 'year';
39
40
    /**
41
     * Ссылка на карточку выпуска
42
     */
43
    const FIELD_URL = 'url';
44
45
    /**
46
     * Ссылка на обложку выпуска
47
     */
48
    const FIELD_THUMB = 'thumb';
49
50
    /**
51
     * Конструктор модели пользователя
52
     *
53
     * @param Client $client Инстанс клиента
54
     * @param array $fields Поля для выборки
55
     *
56
     * @throws Exception
57
     */
58
    public function __construct(Client $client, array $fields = array())
59
    {
60
        parent::__construct($client, $fields);
61
    }
62
63
    /**
64
     * Получение данных для запроса через API
65
     *
66
     * @param string $method Http-метод запроса
67
     * @param array $params Параметры для формирования урла
68
     *
69
     * @return array
70
     *
71
     * @throws Exception
72
     */
73 View Code Duplication
    public function getUrl($method, array $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...
74
    {
75
        switch ($method) {
76
            case 'get':
77
                return array(
78
                    'url' => vsprintf('/1.0/resource/journal/issue/get/%d', $params),
79
                    'method' => 'GET',
80
                    'code' => 200
81
                );
82
            default:
83
                throw new Exception('Route for ' . $method . ' not found');
84
        }
85
    }
86
}