Completed
Pull Request — master (#143)
by Alexander
05:04
created

Databases   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 40
loc 40
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A current() 4 4 1
A add() 10 10 4
A getAll() 4 4 1

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
 * Yandex PHP Library
4
 *
5
 * @copyright NIX Solutions Ltd.
6
 * @link      https://github.com/nixsolutions/yandex-php-library
7
 */
8
namespace Yandex\DataSync\Models;
9
10
use Yandex\Common\ObjectModel;
11
use Yandex\DataSync\Models\Database;
12
13
/**
14
 * Class Databases
15
 *
16
 * @package  Yandex\DataSync\Models
17
 * @author   Alexander Khaylo <[email protected]>
18
 */
19 View Code Duplication
class Databases extends ObjectModel
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...
20
{
21
    protected $collection = [];
22
23
    protected $mappingClasses = [];
24
25
    protected $propNameMap = [];
26
27
    /**
28
     * @return Database
29
     */
30 1
    public function current()
31
    {
32 1
        return parent::current();
33
    }
34
35
    /**
36
     * @param $items
37
     *
38
     * @return $this
39
     */
40 2
    public function add($items)
41
    {
42 2
        if (is_array($items)) {
43 1
            $this->collection[] = new Database($items);
44 2
        } elseif (is_object($items) && $items instanceof Database) {
45 1
            $this->collection[] = $items;
46 1
        }
47
48 2
        return $this;
49
    }
50
51
    /**
52
     * @return Database[]
53
     */
54 1
    public function getAll()
55
    {
56 1
        return $this->collection;
57
    }
58
}
59