join   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 22
dl 0
loc 44
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A recipientOfStringIs() 0 29 1
A __construct() 0 4 1
1
<?php namespace norsys\score\php\string;
2
3
use norsys\score\php\string\{ provider, recipient, recipient\functor, operator };
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, norsys\score\php\string\recipient. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
Bug introduced by
This use statement conflicts with another class in this namespace, norsys\score\php\string\provider. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
4
use norsys\score\php\test\{ defined, recipient\ifTrue\functor as ifTrue };
5
use norsys\score\container\iterator\{ block\functor as iteratorBlock };
6
use norsys\score\container\fifo;
7
8
class join
9
	implements
10
		provider
11
{
12
	private
13
		$glue,
14
		$providers
15
	;
16
17
	function __construct(provider $glue, provider... $providers)
18
	{
19
		$this->glue = $glue;
20
		$this->providers = $providers;
21
	}
22
23
	function recipientOfStringIs(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...
24
	{
25
		$this->glue
26
			->recipientOfStringIs(
27
				new functor(
28
					function($glue) use ($recipient)
29
					{
30
						$buffer = new recipient\buffer\join($glue);
31
32
						(
33
							new fifo(
34
								... $this->providers
35
							)
36
						)
37
							->blockForIteratorIs(
38
								new iteratorBlock(
39
									function($iterator, $provider) use ($buffer)
40
									{
41
										$provider
42
											->recipientOfStringIs(
43
												$buffer
44
											)
45
										;
46
									}
47
								)
48
							)
49
						;
50
51
						$buffer->recipientOfStringIs($recipient);
52
					}
53
				)
54
			)
55
		;
56
	}
57
}
58