File tree Expand file tree Collapse file tree 3 files changed +30
-24
lines changed
Expand file tree Collapse file tree 3 files changed +30
-24
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,12 @@ final class SemverEqualsCondition implements ConditionInterface
1313 use ContextLookup;
1414
1515 private string $ attribute ;
16- private Semver $ value ;
16+ private string $ value ;
1717
18- /**
19- * @throws InvalidArgumentException
20- */
2118 public function __construct (string $ attribute , string $ value )
2219 {
2320 $ this ->attribute = $ attribute ;
24- $ this ->value = new Semver ( $ value) ;
21+ $ this ->value = $ value ;
2522 }
2623
2724 public function isSatisfiedBy (array $ context ): bool
@@ -32,9 +29,13 @@ public function isSatisfiedBy(array $context): bool
3229 }
3330 $ comparator = new VersionComparator ();
3431
35- return $ comparator (
36- new Semver ($ valueFromContext ),
37- $ this ->value
38- ) === 0 ;
32+ try {
33+ return $ comparator (
34+ new Semver ($ valueFromContext ),
35+ new Semver ($ this ->value )
36+ ) === 0 ;
37+ } catch (InvalidArgumentException $ e ) {
38+ return false ;
39+ }
3940 }
4041}
Original file line number Diff line number Diff line change @@ -13,15 +13,12 @@ final class SemverGreaterThanCondition implements ConditionInterface
1313 use ContextLookup, CompositeCondition;
1414
1515 private string $ attribute ;
16- private Semver $ value ;
16+ private string $ value ;
1717
18- /**
19- * @throws InvalidArgumentException
20- */
2118 public function __construct (string $ attribute , string $ value )
2219 {
2320 $ this ->attribute = $ attribute ;
24- $ this ->value = new Semver ( $ value) ;
21+ $ this ->value = $ value ;
2522 }
2623
2724 public function isSatisfiedBy (array $ context ): bool
@@ -32,9 +29,13 @@ public function isSatisfiedBy(array $context): bool
3229 }
3330 $ comparator = new VersionComparator ();
3431
35- return $ comparator (
36- new Semver ($ valueFromContext ),
37- $ this ->value
38- ) === 1 ;
32+ try {
33+ return $ comparator (
34+ new Semver ($ valueFromContext ),
35+ new Semver ($ this ->value )
36+ ) === 1 ;
37+ } catch (InvalidArgumentException $ e ) {
38+ return false ;
39+ }
3940 }
4041}
Original file line number Diff line number Diff line change @@ -13,15 +13,15 @@ final class SemverLessThanCondition implements ConditionInterface
1313 use ContextLookup, CompositeCondition;
1414
1515 private string $ attribute ;
16- private Semver $ value ;
16+ private string $ value ;
1717
1818 /**
1919 * @throws InvalidArgumentException
2020 */
2121 public function __construct (string $ attribute , string $ value )
2222 {
2323 $ this ->attribute = $ attribute ;
24- $ this ->value = new Semver ( $ value) ;
24+ $ this ->value = $ value ;
2525 }
2626
2727 public function isSatisfiedBy (array $ context ): bool
@@ -32,9 +32,13 @@ public function isSatisfiedBy(array $context): bool
3232 }
3333 $ comparator = new VersionComparator ();
3434
35- return $ comparator (
36- new Semver ($ valueFromContext ),
37- $ this ->value
38- ) === -1 ;
35+ try {
36+ return $ comparator (
37+ new Semver ($ valueFromContext ),
38+ new Semver ($ this ->value )
39+ ) === -1 ;
40+ } catch (InvalidArgumentException $ e ) {
41+ return false ;
42+ }
3943 }
4044}
You can’t perform that action at this time.
0 commit comments