fifo::argumentsForBlockAre()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 40
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php namespace norsys\score\trampoline\container;
2
3
use norsys\score\trampoline;
4
use norsys\score\php\block;
5
use norsys\score\container\{
6
	iterator,
7
	iterator\block\functor
8
};
9
10
class fifo
11
	implements
12
		trampoline
13
{
14
	private
15
		$trampolines,
16
		$arguments,
0 ignored issues
show
introduced by
The private property $arguments is not used, and could be removed.
Loading history...
17
		$handler
0 ignored issues
show
introduced by
The private property $handler is not used, and could be removed.
Loading history...
18
	;
19
20
	function __construct(trampoline... $trampolines)
21
	{
22
		$this->trampolines = $trampolines;
23
	}
24
25
	function argumentsForBlockAre(block $block, ... $arguments) :void
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
26
	{
27
		$nothing = function() {};
28
		$callBlock = function() use ($block, & $arguments) {
29
			$block->blockArgumentsAre(... $arguments);
30
		};
31
		$do = $callBlock;
32
33
		(
34
			new iterator\fifo
35
		)
36
			->variablesForIteratorBlockAre(
37
				new functor(
38
					function($iterator, $trampoline) use ($nothing, $callBlock, & $do, & $arguments)
39
					{
40
						$iterator->nextIterationAreUseless();
41
42
						$do = $nothing;
43
44
						$trampoline
45
							->argumentsForBlockAre(
46
								new block\functor(
47
									function(... $argumentsFromTrampoline) use ($iterator, $callBlock, &$do, & $arguments) {
48
										$arguments = array_merge($arguments, $argumentsFromTrampoline);
49
50
										$do = $callBlock;
51
52
										$iterator->nextIterationAreUsefull();
53
									}
54
								),
55
								... $arguments
56
							)
57
						;
58
					}
59
				),
60
				... $this->trampolines
61
			)
62
		;
63
64
		$do();
65
	}
66
}
67