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

ArticleCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 39
loc 39
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() 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\Collection;
4
5
use Exception;
6
use Lan\Ebs\Sdk\Classes\Collection;
7
use Lan\Ebs\Sdk\Client;
8
use Lan\Ebs\Sdk\Model\Article;
9
10 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...
11
{
12
    private $issueId = null;
13
14
    /**
15
     * BookCollection constructor.
16
     * @param Client $client
17
     * @param array $fields
18
     * @param int $limit
19
     * @param int $offset
20
     * @throws Exception
21
     */
22
    public function __construct($issueId, Client $client, array $fields = [], $limit = 10, $offset = 0)
23
    {
24
        parent::__construct($client, $fields, Article::class, $limit, $offset);
25
26
        $this->issueId = $issueId;
27
    }
28
29
    /**
30
     * @param $method
31
     * @param array $params
32
     * @return array
33
     * @throws Exception
34
     */
35
    public function getUrl($method, array $params = [])
36
    {
37
        switch ($method) {
38
            case 'load':
39
                return [
40
                    'url' => '/1.0/resource/journal/issue/' . ((int)$this->issueId),
41
                    'method' => 'GET',
42
                    'code' => '200'
43
                ];
44
            default:
45
                throw new Exception('Route for ' . $method . ' not found');
46
        }
47
    }
48
}