示例#1
0
 /**
  * @param scalar|null $version
  *
  * @return scalar|null
  */
 private function matchVersion($version)
 {
     if (null === $this->versionMatcher || null === $version) {
         return $version;
     } else {
         $matches = $this->versionMatcher->match($version);
         if (isset($matches[0])) {
             return $matches[0];
         }
     }
 }
示例#2
0
 public function testMatch()
 {
     $matcher = new VersionMatcher(['3.4', '1.0', '2.3', '3.2', '2.5']);
     $this->assertEquals(['2.5', '2.3'], $matcher->match('v2'));
     $this->assertEquals([], $matcher->match('v2', false));
     $this->assertEquals(['2.3'], $matcher->match('v2.3', false));
     $this->assertEquals(['3.4'], $matcher->match('3.3'));
     $this->assertEquals(['3.4', '3.2', '1.0'], $matcher->match('^1|^3.2'));
 }