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

ResultFormatRegistrator   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 47
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A withName() 0 4 1
A andMessageKey() 0 4 1
A andParameterDefinitions() 0 4 1
A andPresenterBuilder() 0 4 1
A register() 0 3 1
A newResultFormat() 0 8 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