GoalAddResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 33.33 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 13
loc 39
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getStatus() 0 4 1
A getErrors() 13 13 3

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 Acquia\LiftClient\Entity;
4
5
class GoalAddResponse extends Entity
6
{
7
    /**
8
     * @param array $array
9
     */
10 9
    public function __construct(array $array = [])
11
    {
12 9
        parent::__construct($array);
13 9
    }
14
15
    /**
16
     * Gets the 'status' parameter.
17
     *
18
     * @return string The status of the addition
19
     */
20 9
    public function getStatus()
21
    {
22 9
        return $this->getEntityValue('status', '');
23
    }
24
25
    /**
26
     * Gets the 'status' parameter.
27
     *
28
     * @return LiftError[]|null The errors, if there were any
29
     */
30 6 View Code Duplication
    public function getErrors()
31
    {
32 6
        $ret = [];
33 6
        $errors = $this->getEntityValue('errors', []);
34 6
        if (empty($errors)) {
35
            return null;
36
        }
37 6
        foreach ($errors as $error) {
38 6
            $ret[] = new Error($error);
39 4
        }
40
41 6
        return $ret;
42
    }
43
}
44