ArticleCollection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 79.59 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 39
loc 49
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A getUrl() 4 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 ArticleCollection
4
 *
5
 * @author       Denis Shestakov <[email protected]>
6
 * @copyright    Copyright (c) 2017, Lan Publishing
7
 * @license      MIT
8
 */
9
10
namespace Lan\Ebs\Sdk\Collection;
11
12
use Exception;
13
use Lan\Ebs\Sdk\Classes\Collection;
14
use Lan\Ebs\Sdk\Client;
15
use Lan\Ebs\Sdk\Model\Article;
16
17
/**
18
 * Коллекция статей
19
 *
20
 * @package      Lan\Ebs
21
 * @subpackage   Sdk
22
 * @category     Collection
23
 */
24 View Code Duplication
class ArticleCollection extends Collection
0 ignored issues
show
Duplication introduced by
This class 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...
25
{
26
    /**
27
     * Идентификатор выпуска
28
     *
29
     * @var int
30
     */
31
    private $issueId = null;
32
33
    /**
34
     * BookCollection constructor.
35
     * @param $issueId
36
     * @param Client $client
37
     * @param array $fields
38
     * @param int $limit
39
     * @param int $offset
40
     * @throws Exception
41
     */
42
    public function __construct($issueId, Client $client, array $fields = array(), $limit = 10, $offset = 0)
43
    {
44
        parent::__construct($client, $fields, Article::class, $limit, $offset);
45
46
        $this->issueId = $issueId;
47
    }
48
49
    /**
50
     * Получение данных для запроса через API
51
     *
52
     * @param string $method Http-метод запроса
53
     * @param array $params Параметры для формирования урла
54
     *
55
     * @return array
56
     *
57
     * @throws Exception
58
     */
59
    public function getUrl($method, array $params = array())
60
    {
61
        switch ($method) {
62
            case 'load':
63
                return array(
64
                    'url' => '/1.0/resource/journal/issue/' . ((int)$this->issueId),
65
                    'method' => 'GET',
66
                    'code' => '200'
67
                );
68
            default:
69
                throw new Exception('Route for ' . $method . ' not found');
70
        }
71
    }
72
}