Code Duplication    Length = 49-49 lines in 2 locations

src/OperationList.php 1 location

@@ 7-55 (lines=49) @@
4
5
use Storeman\Operation\OperationInterface;
6
7
class OperationList implements \Countable, \IteratorAggregate
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

src/OperationResultList.php 1 location

@@ 5-53 (lines=49) @@
2
3
namespace Storeman;
4
5
class OperationResultList implements \Countable, \IteratorAggregate
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