|
1
|
|
|
<?php namespace norsys\score\composer\depedency\version\semver; |
|
2
|
|
|
|
|
3
|
|
|
use norsys\score\{ composer\depedency\version\semver, php }; |
|
4
|
|
|
|
|
5
|
|
|
class any |
|
6
|
|
|
implements |
|
7
|
|
|
semver |
|
8
|
|
|
{ |
|
9
|
|
|
private |
|
10
|
|
|
$major, |
|
11
|
|
|
$minor, |
|
12
|
|
|
$patch, |
|
13
|
|
|
$semverToStringConverter |
|
14
|
|
|
; |
|
15
|
|
|
|
|
16
|
|
|
function __construct(semver\number $major = null, semver\number $minor = null, semver\number $patch = null, semver\converter\toString $semverToStringConverter = null) |
|
17
|
|
|
{ |
|
18
|
|
|
$this->major = self::numberIs($major); |
|
19
|
|
|
$this->minor = self::numberIs($minor); |
|
20
|
|
|
$this->patch = self::numberIs($patch); |
|
21
|
|
|
$this->semverToStringConverter = $semverToStringConverter ?: new semver\converter\toString\dot\aggregator; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
function recipientOfMajorNumberInSemverIs(semver\number\recipient $recipient) :void |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
$recipient->semverVersionNumberIs($this->major); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
function recipientOfMajorNumberAsStringFromConverterIs(semver\number\converter\toString $converter, php\string\recipient $recipient) :void |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
$converter->recipientOfSemverNumberAsStringIs($this->major, $recipient); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function recipientOfMinorNumberInSemverIs(semver\number\recipient $recipient) :void |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
$recipient->semverVersionNumberIs($this->minor); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function recipientOfMinorNumberAsStringFromConverterIs(semver\number\converter\toString $converter, php\string\recipient $recipient) :void |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
|
|
$converter->recipientOfSemverNumberAsStringIs($this->minor, $recipient); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
function recipientOfPatchNumberInSemverIs(semver\number\recipient $recipient) :void |
|
|
|
|
|
|
45
|
|
|
{ |
|
46
|
|
|
$recipient->semverVersionNumberIs($this->patch); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
function recipientOfPatchNumberAsStringFromConverterIs(semver\number\converter\toString $converter, php\string\recipient $recipient) :void |
|
|
|
|
|
|
50
|
|
|
{ |
|
51
|
|
|
$converter->recipientOfSemverNumberAsStringIs($this->patch, $recipient); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
function recipientOfStringIs(php\string\recipient $recipient) :void |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
$this->semverToStringConverter |
|
57
|
|
|
->recipientOfSemverVersionAsStringIs( |
|
58
|
|
|
$this, |
|
59
|
|
|
$recipient |
|
60
|
|
|
) |
|
61
|
|
|
; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
private static function numberIs($variable) |
|
65
|
|
|
{ |
|
66
|
|
|
return $variable ?: new semver\number\any; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.