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

OperationList::addOperation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Archivr;
4
5
use Archivr\Operation\OperationInterface;
6
7 View Code Duplication
class OperationList 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...
8
{
9
    /**
10
     * @var OperationInterface[]
11
     */
12
    protected $operations = [];
13
14
    /**
15
     * Adds an operation to the end of the list.
16
     *
17
     * @param OperationInterface $operation
18
     * @return OperationList
19
     */
20
    public function addOperation(OperationInterface $operation): OperationList
21
    {
22
        $this->operations[] = $operation;
23
24
        return $this;
25
    }
26
27
    /**
28
     * Appends another operation list to the end of this list.
29
     *
30
     * @param OperationList $other
31
     * @return OperationList
32
     */
33
    public function append(OperationList $other): OperationList
34
    {
35
        $this->operations = array_merge($this->operations, $other->operations);
36
37
        return $this;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function count()
44
    {
45
        return count($this->operations);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getIterator(): \Iterator
52
    {
53
        return new \ArrayIterator($this->operations);
54
    }
55
}
56