/** * @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; } }
/** * @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(); } }