1 | <?php |
||||
2 | |||||
3 | namespace Fractal\SemVer\Traits; |
||||
4 | |||||
5 | |||||
6 | use Fractal\SemVer\Comparator; |
||||
7 | use Fractal\SemVer\Contracts\VersionInterface; |
||||
8 | |||||
9 | /** |
||||
10 | * Trait Compares |
||||
11 | * |
||||
12 | * @mixin \Fractal\SemVer\Contracts\VersionInterface |
||||
13 | * |
||||
14 | * @author Mikhail Shtanko <[email protected]> |
||||
15 | */ |
||||
16 | trait Compares |
||||
17 | { |
||||
18 | /** |
||||
19 | * Compares version one greater than version two |
||||
20 | * |
||||
21 | * @param \Fractal\SemVer\Contracts\VersionInterface $version |
||||
22 | * |
||||
23 | * @return bool |
||||
24 | * |
||||
25 | * @throws \Fractal\SemVer\Exceptions\InvalidOperatorException |
||||
26 | * @throws \Fractal\SemVer\Exceptions\VersionClassNotEqualException |
||||
27 | */ |
||||
28 | 1 | public function gt(VersionInterface $version): bool |
|||
29 | { |
||||
30 | 1 | return Comparator::gt($this, $version); |
|||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
31 | } |
||||
32 | |||||
33 | /** |
||||
34 | * Compares version one greater than or equal to version two |
||||
35 | * |
||||
36 | * @param \Fractal\SemVer\Contracts\VersionInterface $version |
||||
37 | * |
||||
38 | * @return bool |
||||
39 | * |
||||
40 | * @throws \Fractal\SemVer\Exceptions\InvalidOperatorException |
||||
41 | * @throws \Fractal\SemVer\Exceptions\VersionClassNotEqualException |
||||
42 | */ |
||||
43 | 1 | public function gte(VersionInterface $version): bool |
|||
44 | { |
||||
45 | 1 | return Comparator::gte($this, $version); |
|||
0 ignored issues
–
show
$this of type Fractal\SemVer\Traits\Compares is incompatible with the type Fractal\SemVer\Contracts\VersionInterface expected by parameter $one of Fractal\SemVer\Comparator::gte() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
46 | } |
||||
47 | |||||
48 | /** |
||||
49 | * Compares version one less than version two |
||||
50 | * |
||||
51 | * @param \Fractal\SemVer\Contracts\VersionInterface $version |
||||
52 | * |
||||
53 | * @return bool |
||||
54 | * |
||||
55 | * @throws \Fractal\SemVer\Exceptions\InvalidOperatorException |
||||
56 | * @throws \Fractal\SemVer\Exceptions\VersionClassNotEqualException |
||||
57 | */ |
||||
58 | 1 | public function lt(VersionInterface $version): bool |
|||
59 | { |
||||
60 | 1 | return Comparator::lt($this, $version); |
|||
0 ignored issues
–
show
$this of type Fractal\SemVer\Traits\Compares is incompatible with the type Fractal\SemVer\Contracts\VersionInterface expected by parameter $one of Fractal\SemVer\Comparator::lt() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
61 | } |
||||
62 | |||||
63 | /** |
||||
64 | * Compares version one less than or equal to version two |
||||
65 | * |
||||
66 | * @param \Fractal\SemVer\Contracts\VersionInterface $version |
||||
67 | * |
||||
68 | * @return bool |
||||
69 | * |
||||
70 | * @throws \Fractal\SemVer\Exceptions\InvalidOperatorException |
||||
71 | * @throws \Fractal\SemVer\Exceptions\VersionClassNotEqualException |
||||
72 | */ |
||||
73 | 1 | public function lte(VersionInterface $version): bool |
|||
74 | { |
||||
75 | 1 | return Comparator::lte($this, $version); |
|||
0 ignored issues
–
show
$this of type Fractal\SemVer\Traits\Compares is incompatible with the type Fractal\SemVer\Contracts\VersionInterface expected by parameter $one of Fractal\SemVer\Comparator::lte() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
76 | } |
||||
77 | |||||
78 | /** |
||||
79 | * Compares version one equal to version two |
||||
80 | * |
||||
81 | * @param \Fractal\SemVer\Contracts\VersionInterface $version |
||||
82 | * |
||||
83 | * @return bool |
||||
84 | * |
||||
85 | * @throws \Fractal\SemVer\Exceptions\InvalidOperatorException |
||||
86 | * @throws \Fractal\SemVer\Exceptions\VersionClassNotEqualException |
||||
87 | */ |
||||
88 | 1 | public function eq(VersionInterface $version): bool |
|||
89 | { |
||||
90 | 1 | return Comparator::eq($this, $version); |
|||
0 ignored issues
–
show
$this of type Fractal\SemVer\Traits\Compares is incompatible with the type Fractal\SemVer\Contracts\VersionInterface expected by parameter $one of Fractal\SemVer\Comparator::eq() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
91 | } |
||||
92 | |||||
93 | /** |
||||
94 | * Compares version one not equal to version two |
||||
95 | * |
||||
96 | * @param \Fractal\SemVer\Contracts\VersionInterface $version |
||||
97 | * |
||||
98 | * @return bool |
||||
99 | * |
||||
100 | * @throws \Fractal\SemVer\Exceptions\InvalidOperatorException |
||||
101 | * @throws \Fractal\SemVer\Exceptions\VersionClassNotEqualException |
||||
102 | */ |
||||
103 | 1 | public function ne(VersionInterface $version): bool |
|||
104 | { |
||||
105 | 1 | return Comparator::ne($this, $version); |
|||
0 ignored issues
–
show
$this of type Fractal\SemVer\Traits\Compares is incompatible with the type Fractal\SemVer\Contracts\VersionInterface expected by parameter $one of Fractal\SemVer\Comparator::ne() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
106 | } |
||||
107 | |||||
108 | } |