Completed
Push — master ( 5ba59a...5157fd )
by Denis
02:04
created

Journal   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 89
Duplicated Lines 14.61 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 13
loc 89
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
namespace Lan\Ebs\Sdk\Model;
4
5
use Exception;
6
use Lan\Ebs\Sdk\Classes\Model;
7
use Lan\Ebs\Sdk\Client;
8
9
/**
10
 * @property mixed name
11
 * @property mixed description
12
 * @property mixed issn
13
 * @property mixed eissn
14
 * @property mixed vac
15
 * @property mixed year
16
 * @property mixed issuesPerYear
17
 * @property mixed editors
18
 * @property mixed publisher
19
 * @property mixed url
20
 */
21
class Journal extends Model
22
{
23
    /**
24
     * Наименование журнала
25
     */
26
    const FIELD_NAME = 'name';
27
28
    /**
29
     * Описание журнала
30
     */
31
    const FIELD_DESCRIPTION = 'description';
32
33
    /**
34
     * ISSN журнала
35
     */
36
    const FIELD_ISSN = 'issn';
37
38
    /**
39
     * EISSN журнала
40
     */
41
    const FIELD_EISSN = 'eissn';
42
43
    /**
44
     * Входит в перечень ВАК
45
     */
46
    const FIELD_VAC = 'vac';
47
48
    /**
49
     * Год основания
50
     */
51
    const FIELD_YEAR = 'year';
52
53
    /**
54
     * Выпусков в грд
55
     */
56
    const FIELD_ISSUES_PER_YEAR = 'issuesPerYear';
57
58
    /**
59
     * Редакторы
60
     */
61
    const FIELD_EDITORS = 'editors';
62
63
    /**
64
     * Издательство
65
     */
66
    const FIELD_PUBLISHER = 'publisher';
67
68
    /**
69
     * Ссылка на карточку журнала
70
     */
71
    const FIELD_URL = 'url';
72
73
    /**
74
     * Конструктор модели журнала
75
     *
76
     * @param Client $client Инстанс клиента
77
     * @param array $fields Поля для выборки
78
     *
79
     * @throws Exception
80
     */
81
    public function __construct(Client $client, array $fields = [])
82
    {
83
        parent::__construct($client, $fields);
84
    }
85
86
    /**
87
     * Получение данных для запроса через API
88
     *
89
     * @param string $method Http-метод запроса
90
     * @param array $params Параметры для формирования урла
91
     *
92
     * @return array
93
     *
94
     * @throws Exception
95
     */
96 View Code Duplication
    public function getUrl($method, array $params = [])
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...
97
    {
98
        switch ($method) {
99
            case 'get':
100
                return [
101
                    'url' => vsprintf('/1.0/resource/journal/get/%d', $params),
102
                    'method' => 'GET',
103
                    'code' => 200
104
                ];
105
            default:
106
                throw new Exception('Route for ' . $method . ' not found');
107
        }
108
    }
109
}