Throws exception if prestashop version is not supported
@param int $version The prestashop version
@throws PrestashopWebServiceException
172223
public function isPrestashopVersionSupported($version)
    {
        if (version_compare($version, self::PS_COMPATIBLE_VERSION_MIN, '>=') === false ||
            version_compare($version, self::PS_COMPATIBLE_VERSION_MAX, '<=') === false
        ) {
            $exception = 'This library is not compatible with this version of PrestaShop. ';
            $exception.= 'Please upgrade/downgrade this library';
            throw new PrestashopWebServiceException($exception);
        }
    }
1166027
private function validateProtocolVersion($version): void
    {
        if (empty($version)) {
            throw new \InvalidArgumentException(
                'HTTP protocol version can not be empty'
            );
        }
        if (!\is_string($version)) {
            throw new \InvalidArgumentException(sprintf(
                'Unsupported HTTP protocol version; must be a string, received %s',
                (\is_object($version) ? \get_class($version) : \gettype($version))
            ));
        }

        // HTTP/1 uses a "<major>.<minor>" numbering scheme to indicate
        // versions of the protocol, while HTTP/2 does not.
        if (!\preg_match('#^(1\.[01]|2)$#', $version)) {
            throw new \InvalidArgumentException(\sprintf(
                'Unsupported HTTP protocol version "%s" provided',
                $version
            ));
        }
    }
118213
public static function assertProtocolCompatibility($expectedVersion) {
    if (version_compare(self::PROTOCOL, $expectedVersion, '<')) {
      throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion));
    }
    list ($actualFirst) = explode('.', self::PROTOCOL);
    list ($expectedFirst) = explode('.', $expectedVersion);
    if ($actualFirst > $expectedFirst) {
      throw new InitException(sprintf("civicrm-setup is running protocol v%s. This application expects civicrm-setup to support protocol v%s.", self::PROTOCOL, $expectedVersion));
    }
  }
863277
public function handleVersionedService($version, $service, $resource = null)
    {
        $request = new ServiceRequest();
        $request->setApiVersion($version);

        return $this->handleServiceRequest($request, $service, $resource);
    }
656917
protected function setVersion($version)
    {
        $cleanVer = $this->cleanVersion($version);

        if ($cleanVer == '') {
            $this->_version = self::VERSION_UNKNOWN;
        } else {
            $this->_version = $cleanVer;
        }
    }
890887
public void checkVersion(String version) throws ConnectionException {
        MetaModel meta = createMetaModel();
        meta.getAssetType("Member");

        if ((version != null) && (version.length() > 0)
                && ((meta.getVersion() == null) || (meta.getVersion()
                .compareTo(new Version(version)) < 0))) {
            throw new ConnectionException(MessageFormat.format(
                    "VersionOne Release {0} or above is required (found {1}).",
                    version, meta.getVersion()));
        }
    }
606914
public function setVersion($version) {
        if (in_array($version, self::$_VERSIONS)) {
            $this->_version = $version;
        } else {
            Mage::throwException('Unsupported Varnish version: '.$version);
        }
    }
1355288
public function withProtocolVersion($version)
    {
        Validator::checkProtocolVersion($version);
        $instance = clone $this;
        $instance->protocol = $version;

        return $instance;
    }
171438
public function setApiVersion($apiVersion)
    {
        if ( ! in_array($apiVersion, self::$supportedApiVersions)) {
            throw new ApiVersionNotSupported(sprintf('API version %d is not supported.', $apiVersion));
        }
        $this->apiVersion = $apiVersion;
    }
1223148
public function handleVersionAnnotation($e)
    {
        $annotation = $e->getParam('annotation');
        if (!$annotation instanceof Annotation\Version) {
            return;
        }
    
        $serviceSpec = $e->getParam('serviceSpec');
        $serviceSpec['version'] = $annotation->getVersion();
    }
625082
protected function sysVersionDependency($version)
    {
        $sysVersion = new Version($this->sysMajorVersion.'.'.$this->sysMinorVersion.'.'.$this->sysPathVersion);
        $needVersion = new Version($version);

        if (!$sysVersion->isPartOf($needVersion))
        {
            $this->errors->add('module_dependency_sys', 'This module not made for current version of '.$this->systemName.', made for '.$version);
            return false;
        }
        return false;
    }
1218397
protected function setVersion($version) {
    if ($version == self::V3 || $version == self::V4 || $version == self::V5) {
      $this->version = $version;
    }
    else {
      throw new Exception('An invalid UUID version was specified.');
    }
  }
201783
public function migrate($version = null)
    {
        $migrations     = $this->getMigrations();
        $versions       = $this->getVersions();
        $currentVersion = $this->getCurrentVersion();

        if (!count($migrations)) {
            throw new \RuntimeException('No migrations found.');
        }

        if ($version === null) {
            $version = max(array_merge($versions, array_keys(iterator_to_array($migrations))));
        } else {
            if ($version != 0 && empty($migrations[$version])) {
                throw new \RuntimeException('Version is not valid.');
            }
        }

        // Prepare SQL logs
        if (is_file($this->getLogFile())) {
            File::delete($this->getLogFile());
        }

        Folder::create(dirname($this->getLogFile()));

        $queryLogStream = new Stream($this->getLogFile(), Stream::MODE_WRITE_ONLY_FROM_END);
        $logListener = function (Event $event) use ($queryLogStream) {
            $queryLogStream->write($event['query'] . ";\n\n");
        };
        Ioc::getDispatcher()->listen('onMigrationAfterQuery', $logListener);

        $direction = ($version > $currentVersion) ? AbstractMigration::UP : AbstractMigration::DOWN;

        $migrations = iterator_to_array($migrations);

        $count = 0;

        try {
            if ($direction === AbstractMigration::DOWN) {
                krsort($migrations);

                foreach ($migrations as $migration) {
                    if ($migration['version'] <= $version) {
                        break;
                    }

                    if (in_array($migration['version'], $versions)) {
                        $this->executeMigration($migration, AbstractMigration::DOWN);
                    }

                    $count++;
                }
            }

            ksort($migrations);

            foreach ($migrations as $migration) {
                if ($migration['version'] > $version) {
                    break;
                }

                if (!in_array($migration['version'], $versions, true)) {
                    $this->executeMigration($migration, AbstractMigration::UP);
                }

                $count++;
            }
        } catch (\PDOException $e) {
            $queryLogStream->write("-- ERROR: {$e->getMessage()}\n" . $this->db->getQuery());

            throw $e;
        }

        Ioc::getDispatcher()->removeListener($logListener);

        if (!$count) {
            $this->out('No change.');
        }
    }
358767
public function shouldProcess(Version $version)
    {
        $result = false;
        if (ExifMetadataReader::isSupported()) {
            if ($version->getTypeObject()->getName() == 'JPEG') {
                try {
                    $metadata = $version->hasImagineImage() ? $version->getImagineImage()->metadata() : null;
                    if ($metadata === null) {
                        $fr = $version->getFileResource();
                        $medatadaReader = new ExifMetadataReader();
                        $metadata = $medatadaReader->readData($fr->read());
                    }
                    switch ($metadata->get('ifd0.Orientation', null)) {
                        case 2: // top-right
                        case 3: // bottom-right
                        case 4: // bottom-left
                        case 5: // left-top
                        case 6: // right-top
                        case 7: // right-bottom
                        case 8: // left-bottom
                            $result = true;
                            break;
                    }
                } catch (Exception $x) {
                } catch (Throwable $x) {
                }
            }
        }

        return $result;
    }
1173187
public function withProtocolVersion($version)
    {
        if (in_array($version, ['1.0', '1.1', '2.0']) === false) {
            throw new InvalidArgumentException('You may only use a valid http protocol version, %d provided', $version);
        }

        return $this->_clone('protocol', $version);
    }
940741
public function setHTTPVersion(int $version)
    {
        $this->http_version = ($version === 1 ? '1.0' : '' . $version);

        if ($this->http_version !== '1.0' && $this->http_version !== '1.1') {
            throw new RuntimeException('HTTP version  must be 1.0 or 1.1');
        }
    }
435435
public function setAPIversion($version = '1')
    {
        preg_match('/\d+/', trim($version), $matches);

        if (count($matches) === 1) {
            $this->api_version = $matches[0];
        }
    }