Completed
Push — master ( 1392b0...257c81 )
by Denis
01:57
created

Book   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 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
 * Created by PhpStorm.
4
 * User: dp
5
 * Date: 26.07.17
6
 * Time: 11:57
7
 */
8
9
namespace Lan\Ebs\Sdk\Model;
10
11
use Exception;
12
use Lan\Ebs\Sdk\Classes\Model;
13
use Lan\Ebs\Sdk\Client;
14
15
/**
16
 * @property mixed login
17
 * @property mixed email
18
 * @property mixed fio
19
 * @property mixed registered_at
20
 */
21 View Code Duplication
class Book extends Model
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...
22
{
23
    const FIELD_NAME = 'name';
24
25
    public static $defaultFields = [
26
        Book::FIELD_NAME,
27
    ];
28
29 3
    public function __construct(Client $client, array $fields = [])
30
    {
31 3
        parent::__construct($client, $fields);
32 3
    }
33
34 1
    public function getUrl($method, array $params = [])
35
    {
36
        switch ($method) {
37 1
            case 'get':
38
                return [
39 1
                    'url' => vsprintf('/1.0/resource/book/get/%d', $params),
40 1
                    'method' => 'GET',
41 1
                    'code' => 200
42
                ];
43
            default:
44
                throw new Exception('Route for ' . $method . ' not found');
45
        }
46
    }
47
}