provider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 29
dl 0
loc 64
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A recipientOfStringIs() 0 10 1
A stringIs() 0 31 1
A __construct() 0 4 1
1
<?php namespace norsys\score\php\string\recipient\buffer\prefix;
2
3
use norsys\score\php\block;
4
use norsys\score\{ php, php\string\recipient\functor };
5
use norsys\score\php\test\{ variable\defined, recipient\ifTrue\functor as ifTrue };
6
7
class provider
8
	implements
9
		php\string\recipient,
10
		php\string\provider
11
{
12
	private
13
		$provider,
14
		$buffer
15
	;
16
17
	function __construct(php\string\provider $provider, string $buffer = null)
18
	{
19
		$this->provider = $provider;
20
		$this->buffer = $buffer;
21
	}
22
23
	function stringIs(string $string) :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...
24
	{
25
		$this->provider
26
			->recipientOfStringIs(
27
				new functor(
28
					function($prefix) use ($string)
29
					{
30
						(
31
							new php\string\recipient\prefix(
32
								$prefix,
33
								new functor(
34
									function($prefixedString)
35
									{
36
										(
37
											new php\string\recipient\prefix(
38
												(string) $this->buffer,
39
												new functor(
40
													function($buffer)
41
													{
42
														$this->buffer = $buffer;
43
													}
44
												)
45
											)
46
										)
47
											->stringIs($prefixedString)
48
										;
49
									}
50
								)
51
							)
52
						)
53
							->stringIs($string)
54
						;
55
					}
56
				)
57
			)
58
		;
59
	}
60
61
	function recipientOfStringIs(php\string\recipient $recipient) :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...
62
	{
63
		(
64
			new defined($this->buffer)
65
		)
66
			->recipientOfTestIs(
67
				new ifTrue(
68
					function() use ($recipient)
69
					{
70
						$recipient->stringIs($this->buffer);
0 ignored issues
show
Bug introduced by
It seems like $this->buffer can also be of type null; however, parameter $string of norsys\score\php\string\recipient::stringIs() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

70
						$recipient->stringIs(/** @scrutinizer ignore-type */ $this->buffer);
Loading history...
71
					}
72
				)
73
			)
74
		;
75
	}
76
}
77