예제 #1
0
 /**
  * Checks ifthis range is satisfied by the given version
  * @param  version $version
  * @return boolean
  */
 public function satisfiedBy(version $version)
 {
     $version1 = $version->getVersion();
     $expression = sprintf(self::$regexp_mask, self::$global_single_comparator . self::$global_single_version);
     $ok = false;
     foreach ($this->chunks as $orblocks) {
         //Or loop
         foreach ($orblocks as $ablocks) {
             //And loop
             $matches = array();
             preg_match($expression, $ablocks, $matches);
             $comparators = $matches[1];
             $version2 = $matches[2];
             if ($comparators === '') {
                 $comparators = '==';
                 //Use equal if no comparator is set
             }
             //If one chunk of the and-loop does not match...
             if (!version::cmp($version1, $comparators, $version2)) {
                 $ok = false;
                 //It is not okay
                 break;
                 //And this loop will surely fail: return to or-loop
             } else {
                 $ok = true;
             }
         }
         if ($ok) {
             return true;
             //Only one or block has to match
         }
     }
     return false;
     //No matches found :(
 }