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

IssueCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
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 40
loc 40
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\Issue;
9
10 View Code Duplication
class IssueCollection 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 $journalId = null;
13
14
    /**
15
     * BookCollection constructor.
16
     * @param $journalId
17
     * @param Client $client
18
     * @param array $fields
19
     * @param int $limit
20
     * @param int $offset
21
     * @throws Exception
22
     */
23
    public function __construct($journalId, Client $client, array $fields = [], $limit = 10, $offset = 0)
24
    {
25
        parent::__construct($client, $fields, Issue::class, $limit, $offset);
26
27
        $this->journalId = $journalId;
28
    }
29
30
    /**
31
     * @param $method
32
     * @param array $params
33
     * @return array
34
     * @throws Exception
35
     */
36
    public function getUrl($method, array $params = [])
37
    {
38
        switch ($method) {
39
            case 'load':
40
                return [
41
                    'url' => '/1.0/resource/journal/' . ((int)$this->journalId),
42
                    'method' => 'GET',
43
                    'code' => '200'
44
                ];
45
            default:
46
                throw new Exception('Route for ' . $method . ' not found');
47
        }
48
    }
49
}