diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-16 23:31:35 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-16 23:31:35 +0900 |
| commit | 5b3d5a44c86fed94fc9d915943b728903f09c8ca (patch) | |
| tree | 4bb7d62e81fc8748744a9d0f2f495da3e74e2288 | |
| parent | 303811ce071865ffd1ea02a5d5ff0ca5537179bd (diff) | |
| download | php-shirabe-5b3d5a44c86fed94fc9d915943b728903f09c8ca.tar.gz php-shirabe-5b3d5a44c86fed94fc9d915943b728903f09c8ca.tar.zst php-shirabe-5b3d5a44c86fed94fc9d915943b728903f09c8ca.zip | |
feat(port): port MatchAllConstraint.php
| -rw-r--r-- | crates/shirabe-semver/src/constraint/match_all_constraint.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/crates/shirabe-semver/src/constraint/match_all_constraint.rs b/crates/shirabe-semver/src/constraint/match_all_constraint.rs index 7ba02cc..e877735 100644 --- a/crates/shirabe-semver/src/constraint/match_all_constraint.rs +++ b/crates/shirabe-semver/src/constraint/match_all_constraint.rs @@ -1 +1,44 @@ //! ref: composer/vendor/composer/semver/src/Constraint/MatchAllConstraint.php + +use crate::constraint::bound::Bound; +use crate::constraint::constraint_interface::ConstraintInterface; + +#[derive(Debug)] +pub struct MatchAllConstraint { + pub(crate) pretty_string: Option<String>, +} + +impl ConstraintInterface for MatchAllConstraint { + fn matches(&self, _provider: &dyn ConstraintInterface) -> bool { + true + } + + fn compile(&self, _other_operator: i64) -> String { + "true".to_string() + } + + fn set_pretty_string(&mut self, pretty_string: Option<String>) { + self.pretty_string = pretty_string; + } + + fn get_pretty_string(&self) -> String { + if let Some(ref s) = self.pretty_string { + if !s.is_empty() { + return s.clone(); + } + } + self.__to_string() + } + + fn __to_string(&self) -> String { + "*".to_string() + } + + fn get_upper_bound(&self) -> Bound { + Bound::positive_infinity() + } + + fn get_lower_bound(&self) -> Bound { + Bound::zero() + } +} |
