Passed
Push — master ( 7333b2...254881 )
by Frédéric
01:43
created

dot::recipientOfSemverVersionAsStringIs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 58
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 58
rs 9.44
c 0
b 0
f 0
cc 1
nc 1
nop 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php namespace norsys\score\composer\depedency\version\semver\converter\toString;
2
3
use norsys\score\{ trampoline, composer\depedency\version\semver, php };
4
5
class dot
6
	implements
7
		semver\converter\toString
8
{
9
	private
10
		$majorToString,
11
		$minorToString,
12
		$patchToString
13
	;
14
15
	function __construct(semver\number\converter\toString $majorToString = null, semver\number\converter\toString $minorToString = null, semver\number\converter\toString $patchToString = null)
16
	{
17
		$this->majorToString = $majorToString ?: new semver\number\converter\toString\identical;
18
		$this->minorToString = $minorToString ?: new semver\number\converter\toString\identical;
19
		$this->patchToString = $patchToString ?: new semver\number\converter\toString\identical;
20
	}
21
22
	function recipientOfMajorInSemverVersionAsStringIs(semver $semver, 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...
23
	{
24
		$semver
25
			->recipientOfMajorNumberAsStringFromConverterIs(
26
				$this->majorToString,
27
				$recipient
28
			)
29
		;
30
	}
31
32
	function recipientOfMinorInSemverVersionAsStringIs(semver $semver, 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...
33
	{
34
		$semver
35
			->recipientOfMinorNumberAsStringFromConverterIs(
36
				$this->minorToString,
37
				$recipient
38
			)
39
		;
40
	}
41
42
	function recipientOfPatchInSemverVersionAsStringIs(semver $semver, 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...
43
	{
44
		$semver
45
			->recipientOfPatchNumberAsStringFromConverterIs(
46
				$this->patchToString,
47
				$recipient
48
			)
49
		;
50
	}
51
52
	function recipientOfSemverVersionAsStringIs(semver $semver, 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...
53
	{
54
		(
55
			new trampoline\container\fifo(
56
				new trampoline\functor(
57
					function($block) use ($semver)
58
					{
59
						$this
60
							->recipientOfMajorInSemverVersionAsStringIs(
61
								$semver,
62
								new php\string\recipient\block($block)
63
							)
64
						;
65
					}
66
				),
67
				new trampoline\functor(
68
					function($block) use ($semver)
69
					{
70
						$this
71
							->recipientOfMinorInSemverVersionAsStringIs(
72
								$semver,
73
								new php\string\recipient\block($block)
74
							)
75
						;
76
					}
77
				),
78
				new trampoline\functor(
79
					function($block) use ($semver)
80
					{
81
						$this
82
							->recipientOfPatchInSemverVersionAsStringIs(
83
								$semver,
84
								new php\string\recipient\block($block)
85
							)
86
						;
87
					}
88
				)
89
			)
90
		)
91
			->argumentsForBlockAre(
92
				new php\block\functor(
93
					function($recipient, $major, $minor, $patch)
94
					{
95
						(
96
							new php\string\operator\unary\join(
97
								$major,
98
								$minor,
99
								$patch
100
							)
101
						)
102
							->recipientOfStringOperationWithStringIs(
103
								'.',
104
								$recipient
105
							)
106
						;
107
					}
108
				),
109
				$recipient
110
			)
111
		;
112
	}
113
}
114