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()) |
|
|
|
|
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
|
|
|
} |
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.