Completed
Push — master ( c5a3b4...fa0d52 )
by Arne
01:49
created

OperationResultList   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 49
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addOperationResult() 6 6 1
A append() 6 6 1
A count() 4 4 1
A getIterator() 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
namespace Archivr;
4
5 View Code Duplication
class OperationResultList implements \Countable, \IteratorAggregate
1 ignored issue
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...
6
{
7
    /**
8
     * @var OperationResult[]
9
     */
10
    protected $operationResults = [];
11
12
    /**
13
     * Adds an operation result to the end of the list.
14
     *
15
     * @param OperationResult $operationResult
16
     * @return OperationResultList
17
     */
18
    public function addOperationResult(OperationResult $operationResult): OperationResultList
19
    {
20
        $this->operationResults[] = $operationResult;
21
22
        return $this;
23
    }
24
25
    /**
26
     * Appends another operation result list to the end of this list.
27
     *
28
     * @param OperationResultList $other
29
     * @return OperationResultList
30
     */
31
    public function append(OperationResultList $other): OperationResultList
32
    {
33
        $this->operationResults = array_merge($this->operationResults, $other->operationResults);
34
35
        return $this;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function count()
42
    {
43
        return count($this->operationResults);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getIterator()
50
    {
51
        return new \ArrayIterator($this->operationResults);
52
    }
53
}
54