Completed
Push — master ( 93e4df...65b5d6 )
by Jeroen De
01:49
created

ProcessingResult::getParameterArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace ParamProcessor;
4
5
/**
6
 * @since 1.0
7
 *
8
 * @licence GNU GPL v2+
9
 * @author Jeroen De Dauw < [email protected] >
10
 */
11
class ProcessingResult {
12
13
	private $parameters;
14
	private $errors;
15
16
	/**
17
	 * @param ProcessedParam[] $parameters
18
	 * @param ProcessingError[] $errors
19
	 */
20 7
	public function __construct( array $parameters, array $errors = [] ) {
21 7
		$this->parameters = $parameters;
22 7
		$this->errors = $errors;
23 7
	}
24
25
	/**
26
	 * @return ProcessedParam[]
27
	 */
28 1
	public function getParameters(): array {
29 1
		return $this->parameters;
30
	}
31
32
	/**
33
	 * @since 1.8
34
	 */
35 2
	public function getParameterArray(): array {
36 2
		$parameters = [];
37
38 2
		foreach ( $this->parameters as $parameter ) {
39 1
			$parameters[$parameter->getName()] = $parameter->getValue();
40
		}
41
42 2
		return $parameters;
43
	}
44
45
	/**
46
	 * @return ProcessingError[]
47
	 */
48 1
	public function getErrors(): array {
49 1
		return $this->errors;
50
	}
51
52 3
	public function hasFatal(): bool {
53 3
		foreach ( $this->errors as $error ) {
54 2
			if ( $error->isFatal() ) {
55 1
				return true;
56
			}
57
		}
58
59 2
		return false;
60
	}
61
62
}
63