コード例 #1
0
 /**
  * @param array $versions
  */
 public function __construct(array $versions)
 {
     foreach ($versions as $version) {
         if (is_string($version)) {
             $version = Version::fromString($version);
         } elseif (!$version instanceof Version) {
             throw new InvalidArgumentException(sprintf('Item in the versions array should be either string or Version instance, %s given', gettype($version)));
         }
         $this->versions[] = $version;
     }
 }
コード例 #2
0
ファイル: AbstractParser.php プロジェクト: nikolaposa/version
 /**
  * @param string $constraintStringUnit
  * @return Constraint
  */
 protected function buildConstraintFromStringUnit($constraintStringUnit)
 {
     list($operator, $operandString) = array_values($this->parseConstraintStringUnit($constraintStringUnit));
     if (empty($operandString)) {
         $this->error();
     }
     try {
         return Constraint::fromProperties($operator ?: Constraint::OPERATOR_EQ, Version::fromString($operandString));
     } catch (Exception $ex) {
         $this->error();
     }
 }