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

Databases::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
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