Completed
Push — master ( c14aad...5ba59a )
by Denis
06:56
created

BookCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 60 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 21
loc 35
ccs 8
cts 11
cp 0.7272
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A getUrl() 0 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
 * Created by PhpStorm.
4
 * User: dp
5
 * Date: 26.07.17
6
 * Time: 12:25
7
 */
8
9
namespace Lan\Ebs\Sdk\Collection;
10
11
use Exception;
12
use Lan\Ebs\Sdk\Classes\Collection;
13
use Lan\Ebs\Sdk\Client;
14
use Lan\Ebs\Sdk\Model\Book;
15
16 View Code Duplication
class BookCollection 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...
17
{
18
    /**
19
     * BookCollection constructor.
20
     * @param Client $client
21
     * @param array $fields
22
     * @param int $limit
23
     * @param int $offset
24
     * @throws Exception
25
     */
26 2
    public function __construct(Client $client, array $fields = [], $limit = 10, $offset = 0)
27
    {
28 2
        parent::__construct($client, $fields, Book::class, $limit, $offset);
29 2
    }
30
31
    /**
32
     * @param $method
33
     * @param array $params
34
     * @return array
35
     * @throws Exception
36
     */
37 2
    public function getUrl($method, array $params = [])
38
    {
39
        switch ($method) {
40 2
            case 'load':
41
                return [
42 2
                    'url' => '/1.0/resource/book',
43 2
                    'method' => 'GET',
44
                    'code' => '200'
45 2
                ];
46
            default:
47
                throw new Exception('Route for ' . $method . ' not found');
48
        }
49
    }
50
}