Journal   A
last analyzed

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