Passed
Push — master ( 4d3a7d...14719f )
by Gabriel
01:41 queued 35s
created

ChangeAddressResponse   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 38
rs 10
ccs 11
cts 11
cp 1
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getErrors() 0 2 1
A newSuccessResponse() 0 2 1
A newErrorResponse() 0 2 1
A isSuccess() 0 2 1
A __construct() 0 2 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\AddressChangeContext\UseCases\ChangeAddress;
6
7
class ChangeAddressResponse {
8
9
	public const ERROR_ADDRESS_NOT_FOUND = 'Address not found';
10
11
	/**
12
	 * @var array<string>
13
	 */
14
	private array $errorMessages;
15
16
	/**
17
	 * @param array<string> $errorMessages
18
	 */
19 5
	private function __construct( array $errorMessages = [] ) {
20 5
		$this->errorMessages = $errorMessages;
21 5
	}
22
23
	/**
24
	 * @param array<string> $errorMessages
25
	 *
26
	 * @return ChangeAddressResponse
27
	 */
28 3
	public static function newErrorResponse( array $errorMessages ): self {
29 3
		return new self( $errorMessages );
30
	}
31
32 2
	public static function newSuccessResponse(): self {
33 2
		return new self();
34
	}
35
36 5
	public function isSuccess(): bool {
37 5
		return count( $this->errorMessages ) === 0;
38
	}
39
40
	/**
41
	 * @return array<string>
42
	 */
43 1
	public function getErrors(): array {
44 1
		return $this->errorMessages;
45
	}
46
47
}
48