Completed
Pull Request — master (#155)
by Alexander
05:35
created

Accounts   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 88.57 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 2 Features 1
Metric Value
wmc 5
c 4
b 2
f 1
lcom 1
cbo 2
dl 31
loc 35
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 10 10 4
A getAll() 1 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
namespace Yandex\Metrica\Management\Models;
4
5
use Yandex\Common\ObjectModel;
6
7 View Code Duplication
class Accounts 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...
8
{
9
10
    protected $collection = [];
11
12
    protected $mappingClasses = [];
13
14
    protected $propNameMap = [];
15
16
    /**
17
     * Add item
18
     * @param Account $account
19
     *
20
     * @return $this
21
     */
22 6
    public function add($account)
23
    {
24 6
        if (is_array($account)) {
25 6
            $this->collection[] = new Account($account);
26 6
        } elseif (is_object($account) && $account instanceof Account) {
27 1
            $this->collection[] = $account;
28 1
        }
29
30 6
        return $this;
31
    }
32
33
    /**
34
     * Get items
35
     * @return Account[]
36
     */
37 1
    public function getAll()
38
    {
39 1
        return $this->collection;
40
    }
41
}
42