MutationErrorCollection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php declare(strict_types = 1);
2
3
namespace TomCizek\ResponseRecorder\Application\ResponseRecorder\MutationResponse;
4
5
use ArrayIterator;
6
use Countable;
7
use Iterator;
8
use IteratorAggregate;
9
use TomCizek\ResponseRecorder\Application\ResponseRecorder\MutationResponse\ErrorCollection\ShowableMutationError;
10
11
class MutationErrorCollection implements Countable, IteratorAggregate
12
{
13
	/** @var ShowableMutationError[] */
14
	protected $errors = [];
15
16
	/**
17
	 * @param ShowableMutationError[] $errorDomainEvents
18
	 */
19 9
	public function __construct(array $errorDomainEvents)
20
	{
21 9
		$this->errors = $errorDomainEvents;
22 9
	}
23
24 9
	public function count(): int
25
	{
26 9
		return count($this->errors);
27
	}
28
29
	/**
30
	 * @return ShowableMutationError[]
31
	 */
32 5
	public function getAll(): array
33
	{
34 5
		return $this->errors;
35
	}
36
37
	/**
38
	 * @return Iterator|ShowableMutationError[]
39
	 */
40
	public function getIterator(): Iterator
41
	{
42
		return new ArrayIterator($this->errors);
43
	}
44
}
45