Completed
Push — master ( 2623ee...a82f7c )
by Jeroen De
06:13 queued 04:44
created

ResultFormatRegistrator::andParameterDefinitions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
nc 1
nop 1
crap 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace ModernTimeline\ResultFacade;
6
7
class ResultFormatRegistrator {
8
9
	private $registry;
10
11
	private $name;
12
	private $nameMessageKey;
13
	private $parameterDefinitions;
14
	private $constructionFunction;
15
16 5
	public function __construct( callable $registry ) {
17 5
		$this->registry = $registry;
18 5
	}
19
20 5
	public function withName( string $name ): self {
21 5
		$this->name = $name;
22 5
		return $this;
23
	}
24
25 5
	public function andMessageKey( string $nameMessageKey ): self {
26 5
		$this->nameMessageKey = $nameMessageKey;
27 5
		return $this;
28
	}
29
30 5
	public function andParameterDefinitions( array $parameterDefinitions ): self {
31 5
		$this->parameterDefinitions = $parameterDefinitions;
32 5
		return $this;
33
	}
34
35 5
	public function andPresenterBuilder( callable $constructionFunction ): self {
36 5
		$this->constructionFunction = $constructionFunction;
37 5
		return $this;
38
	}
39
40 5
	public function register() {
41 5
		call_user_func( $this->registry, $this->newResultFormat() );
42 5
	}
43
44 5
	private function newResultFormat(): ResultFormat {
45 5
		return new ResultFormat(
46 5
			$this->name,
47 5
			$this->nameMessageKey,
48 5
			$this->parameterDefinitions,
49 5
			$this->constructionFunction
50
		);
51
	}
52
53
}
54