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

Issue::getUrl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 13
loc 13
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 2
crap 6
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 year
12
 * @property mixed url
13
 * @property mixed thumb
14
 */
15
class Issue extends Model
16
{
17
    /**
18
     * Номер выпуска
19
     */
20
    const FIELD_NAME = 'name';
21
22
    /**
23
     * Год выпуска
24
     */
25
    const FIELD_YEAR = 'year';
26
27
    /**
28
     * Ссылка на карточку выпуска
29
     */
30
    const FIELD_URL = 'url';
31
32
    /**
33
     * Ссылка на обложку выпуска
34
     */
35
    const FIELD_THUMB = 'thumb';
36
37
    /**
38
     * Конструктор модели пользователя
39
     *
40
     * @param Client $client Инстанс клиента
41
     * @param array $fields Поля для выборки
42
     *
43
     * @throws Exception
44
     */
45
    public function __construct(Client $client, array $fields = [])
46
    {
47
        parent::__construct($client, $fields);
48
    }
49
50
    /**
51
     * Получение данных для запроса через API
52
     *
53
     * @param string $method Http-метод запроса
54
     * @param array $params Параметры для формирования урла
55
     *
56
     * @return array
57
     *
58
     * @throws Exception
59
     */
60 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...
61
    {
62
        switch ($method) {
63
            case 'get':
64
                return [
65
                    'url' => vsprintf('/1.0/resource/journal/issue/get/%d', $params),
66
                    'method' => 'GET',
67
                    'code' => 200
68
                ];
69
            default:
70
                throw new Exception('Route for ' . $method . ' not found');
71
        }
72
    }
73
}