original_string: public function match(Version $version)
      {
          $versionStabilityIndex = array_search($version->getStability(), Version::$stabilities);
          $constraintStabilityIndex = array_search($this->stability, Version::$stabilities);
  
          if ($this->compare($versionStabilityIndex, $constraintStabilityIndex) !== 0) {
              return false;
          }
  
          $numericValues = $version->numeric();
          $comparisons = array();
  
          foreach ($this->version as $i => $value) {
              $comparisons[$i] = $this->compare($numericValues[$i], $value);
          }
  
          switch ($this->operator) {
              case '=': case '==':
                  // all parts must be equal:
                  return array_filter($comparisons) === array();
                  break;
              case '!': case '!=':
                  // any part must be unequal:
                  return array_filter($comparisons) !== array();
                  break;
              case '>=':
              case '<=':
              case '>':
              case '<':
                  // the first mismatch is the tie breaker
                  $mismatches = array_filter($comparisons);
                  if (!count($mismatches)) {
                      // if no mismatches, only ok if equality operator
                      return in_array($this->operator, array('<=', '>='));
                  } else {
                      $first = array_shift($mismatches);
                      return
                             ($this->operator === '<'  && $first < 0)
                          || ($this->operator === '<=' && $first < 0)
                          || ($this->operator === '>'  && $first > 0)
                          || ($this->operator === '>=' && $first > 0)
                      ;
                  }
          }
  
          throw new \UnexpectedValueException("An unknown edge case was encountered. Is the constraint valid?");
      }
code: public function match(Version $version)
      {
          $versionStabilityIndex = array_search($version->getStability(), Version::$stabilities);
          $constraintStabilityIndex = array_search($this->stability, Version::$stabilities);
  
          if ($this->compare($versionStabilityIndex, $constraintStabilityIndex) !== 0) {
              return false;
          }
  
          $numericValues = $version->numeric();
          $comparisons = array();
  
          foreach ($this->version as $i => $value) {
              $comparisons[$i] = $this->compare($numericValues[$i], $value);
          }
  
          switch ($this->operator) {
              case '=': case '==':
                  // all parts must be equal:
                  return array_filter($comparisons) === array();
                  break;
              case '!': case '!=':
                  // any part must be unequal:
                  return array_filter($comparisons) !== array();
                  break;
              case '>=':
              case '<=':
              case '>':
              case '<':
                  // the first mismatch is the tie breaker
                  $mismatches = array_filter($comparisons);
                  if (!count($mismatches)) {
                      // if no mismatches, only ok if equality operator
                      return in_array($this->operator, array('<=', '>='));
                  } else {
                      $first = array_shift($mismatches);
                      return
                             ($this->operator === '<'  && $first < 0)
                          || ($this->operator === '<=' && $first < 0)
                          || ($this->operator === '>'  && $first > 0)
                          || ($this->operator === '>=' && $first > 0)
                      ;
                  }
          }
  
          throw new \UnexpectedValueException("An unknown edge case was encountered. Is the constraint valid?");
      }
code_tokens: public function match ( Version $ version ) { $ versionStabilityIndex = array_search ( $ version -> getStability ( ) , Version :: $ stabilities ) ; $ constraintStabilityIndex = array_search ( $ this -> stability , Version :: $ stabilities ) ; if ( $ this -> compare ( $ versionStabilityIndex , $ constraintStabilityIndex ) !== 0 ) { return false ; } $ numericValues = $ version -> numeric ( ) ; $ comparisons = array ( ) ; foreach ( $ this -> version as $ i => $ value ) { $ comparisons [ $ i ] = $ this -> compare ( $ numericValues [ $ i ] , $ value ) ; } switch ( $ this -> operator ) { case '=' : case '==' : // all parts must be equal: return array_filter ( $ comparisons ) === array ( ) ; break ; case '!' : case '!=' : // any part must be unequal: return array_filter ( $ comparisons ) !== array ( ) ; break ; case '>=' : case '<=' : case '>' : case '<' : // the first mismatch is the tie breaker $ mismatches = array_filter ( $ comparisons ) ; if ( ! count ( $ mismatches ) ) { // if no mismatches, only ok if equality operator return in_array ( $ this -> operator , array ( '<=' , '>=' ) ) ; } else { $ first = array_shift ( $ mismatches ) ; return ( $ this -> operator === '<' && $ first < 0 ) || ( $ this -> operator === '<=' && $ first < 0 ) || ( $ this -> operator === '>' && $ first > 0 ) || ( $ this -> operator === '>=' && $ first > 0 ) ; } } throw new \ UnexpectedValueException ( "An unknown edge case was encountered. Is the constraint valid?" ) ; }
docstring: Match the constraint against the passed version.
  
  @param Version $version
  @return bool
  
  @throws \UnexpectedValueException
docstring_tokens: Match the constraint against the passed version .