UserCollection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 40
loc 40
ccs 6
cts 7
cp 0.8571
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
 * Class UserCollection
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\User;
16
17
/**
18
 * Коллекция пользователей
19
 *
20
 * @package      Lan\Ebs
21
 * @subpackage   Sdk
22
 * @category     Collection
23
 */
24 View Code Duplication
class UserCollection 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
     * UserCollection constructor.
28
     *
29
     * @param Client $client
30
     * @param array $fields
31
     * @param int $limit
32
     * @param int $offset
33
     * @throws Exception
34
     */
35 1
    public function __construct(Client $client, array $fields = array(), $limit = 10, $offset = 0)
36
    {
37 1
        parent::__construct($client, $fields, User::class, $limit, $offset);
38 1
    }
39
40
    /**
41
     * Получение данных для запроса через API
42
     *
43
     * @param string $method Http-метод запроса
44
     * @param array $params Параметры для формирования урла
45
     *
46
     * @return array
47
     *
48
     * @throws Exception
49
     */
50 1
    public function getUrl($method, array $params = array())
51
    {
52
        switch ($method) {
53 1
            case 'load':
54
                return array(
55 1
                    'url' => '/1.0/security/user',
56
                    'method' => 'GET',
57
                    'code' => '200'
58
                );
59
            default:
60
                throw new Exception('Route for ' . $method . ' not found');
61
        }
62
    }
63
}