Completed
Push — master ( dd23a3...589bb6 )
by Nick
05:48 queued 02:41
created

CapturesResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 35.14 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 13
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrors() 13 13 3
A getMatchedSegments() 0 10 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
namespace Acquia\LiftClient\Entity;
4
5
class CapturesResponse extends CapturesBase
6
{
7
    /**
8
     * Gets the 'status' parameter.
9
     *
10
     * @return Error[]|null The errors, if there were any
11
     */
12 View Code Duplication
    public function getErrors()
13
    {
14
        $ret = [];
15
        $errors = $this->getEntityValue('errors', []);
16
        if (empty($errors)) {
17
            return null;
18
        }
19
        foreach ($errors as $error) {
20
            $ret[] = new Error($error);
21
        }
22
23
        return $ret;
24
    }
25
26
    /**
27
     * Gets the 'matched_segments' parameter.
28
     *
29
     * @return Segment[]
30
     */
31
    public function getMatchedSegments()
32
    {
33
        $ret = [];
34
        $segments = $this->getEntityValue('matched_segments', []);
35
        foreach ($segments as $segment) {
36
            $ret[] = new Segment($segment);
37
        }
38
39
        return $ret;
40
    }
41
}
42