Assert min protoc version.

@throws \UnexpectedValueException Indicates a problem with protoc.
513420
public function assertVersion()
    {
        $process = $this->createProtocVersionProcess();

        // Check if protoc is available
        $process->mustRun();

        $return = $process->getExitCode();
        $result = trim($process->getOutput());

        if (0 !== $return && 1 !== $return) {
            throw new UnexpectedValueException("Unable to find the protoc command. Please make sure it's installed and available in the path.");
        }

        if ( ! preg_match('/[0-9\.]+/', $result, $match)) {
            throw new UnexpectedValueException("Unable to get protoc command version. Please make sure it's installed and available in the path.");
        }

        if (version_compare($match[0], $this->version) < 0) {
            throw new UnexpectedValueException("The protoc command in your system is too old. Minimum version required is '{$this->version}' but found '$result'.");
        }
    }
1281035
private static function validateComp($component, $value, $min, $max)
    {
        if ($value < $min || $value > $max) {
            throw new Exception(
              "{$component} component {$value} must be {$min}-{$max}");
        }
    }
383258
public function checkServerVersion()
    {
        $databaseVersion = $this->getServerVersion();
        $requiredVersion = Config::getInstance()->General['minimum_pgsql_version'];

        if (version_compare($databaseVersion, $requiredVersion) === -1) {
            throw new Exception(Piwik::translate('General_ExceptionDatabaseVersion', array('PostgreSQL', $databaseVersion, $requiredVersion)));
        }
    }
796755
public function checkClientVersion()
    {
        $serverVersion = $this->getServerVersion();
        $clientVersion = $this->getClientVersion();

        if (version_compare($serverVersion, '10') >= 0
            && version_compare($clientVersion, '10') < 0
        ) {
            throw new Exception(Piwik::translate('General_ExceptionIncompatibleClientServerVersions', array('MSSQL', $clientVersion, $serverVersion)));
        }
    }
272649
public function verify()
    {
        if ($this->currentIndex < $this->sequenceIndex) {
            throw new PHPUnit_Framework_ExpectationFailedException(
              sprintf(
                "The expected invocation at method '%s' index %d was never reached.",

                $this->method,
                $this->sequenceIndex
              )
            );
        }
    }
876840
public function postFlush(PostFlushEventArgs $e)
    {
        $repo = $e->getEntityManager()->getRepository($this->entityName);
        if (true !== ($issues = $repo->verify())) {
            throw new \UnexpectedValueException(
                sprintf(
                    "The repository '%s' did not validate. Run the '%s' console command to find out what's going on",
                    $this->entityName,
                    RepairNestedTreeCommand::COMMAND_NAME
                )
            );
        }
    }
547372
public function assertIsArrayAndNotEmpty($value, $message='%s must not be an empty Array', $exception='Asserts')
    {
        if (isset($value) === false || is_array($value) === false || (is_array($value) && count($value) <= 0)) {
            $this->throwException($exception, $message, $value);
        }
    }
974238
private function invalidReturnValue(string $what, string $expected, $actual) : \UnexpectedValueException
    {
        $message = 'Invalid return value from %s: expected %s, got %s.';
        $actual  = is_object($actual) ? get_class($actual) : gettype($actual);

        return new \UnexpectedValueException(sprintf($message, $what, $expected, $actual));
    }
72415
protected function checkValue(): void
    {
        if (!ctype_digit($this->value) && !is_numeric($this->value) && !empty($this->value)) {
            throw new InvalidArgumentException('NumericParser: Value must be of type numeric');
        }
    }
990947
protected function build()
    {
        $closure = $this['closure'];
        /** @var $closure \Closure */
        $this->request = $closure($this, $this->operation);

        if (!$this->request || !$this->request instanceof RequestInterface) {
            throw new UnexpectedValueException('Closure command did not return a RequestInterface object');
        }
    }
1371479
public function validateCall(): void
    {

        if (! in_array($this->method, ['get', 'post', 'put', 'patch', 'delete']))
            throw new Exception('Invalid HTTP method used');

        if (trim($this->endpoint) === '')
            throw new Exception('Empty endpoint used');

        // Enfore a version specification unless this is a 'meta' call.
        if (trim($this->version) === '' && ! (in_array('meta', $this->tags())))
            throw new Exception('Version is empty');
    }
681280
public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof Json) {
            throw new UnexpectedTypeException($constraint, Json::class);
        }

        if (null === $value || '' === $value) {
            return;
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            throw new UnexpectedTypeException($value, 'string');
        }

        if (json_decode($value) || json_last_error() === JSON_ERROR_NONE) {
            return;
        }

        $this->context->buildViolation($constraint->message)
            ->setParameter('{{ value }}', $this->formatValue($value))
            ->addViolation();
    }
1099468
public function checkPHPversion(string $minPhpVersion = null)
    {
        $minVersionPhp = $minPhpVersion;
        $currentPhpVersion = $this->getPhpVersionInfo();
        $supported = false;

        if ($minPhpVersion == null) {
            $minVersionPhp = $this->getMinPhpVersion();
        }

        if (version_compare($currentPhpVersion['version'], $minVersionPhp) >= 0) {
            $supported = true;
        }

        $phpStatus = [
            'full' => $currentPhpVersion['full'],
            'current' => $currentPhpVersion['version'],
            'minimum' => $minVersionPhp,
            'supported' => $supported
        ];

        return $phpStatus;
    }
744840
public function exec()
    {
        $this->response = '';
        $errno = $errstr = null;

        if (isset($this->context)) {
            $this->stream = stream_socket_client($this->socket, $errno, $errstr, $this->timeout, STREAM_CLIENT_CONNECT, $this->context);
        } else {
            $this->stream = stream_socket_client($this->socket, $errno, $errstr, $this->timeout);
        }

        if (!empty($errstr)) {
            throw new UnexpectedValueException($errstr);
        }

        fwrite($this->stream, $this->getRequestBody());

        while (!feof($this->stream)) {
            $this->response .= fgets($this->stream, 1024);
        }

        fclose($this->stream);
        $this->stream = null;

        return $this;
    }
912058
public function checkPhpVersion(array $module)
    {
        if (!empty($module['php'])) {

            $components = $this->getVersionComponents($module['php']);

            if (empty($components)) {
                throw new UnexpectedValueException($this->translation->text('Failed to read PHP version'));
            }

            list($operator, $number) = $components;

            if (!version_compare(PHP_VERSION, $number, $operator)) {
                $error = $this->translation->text('Requires incompatible version of @name', array('@name' => 'PHP'));
                throw new UnexpectedValueException($error);
            }
        }

        return true;
    }
694658
private function validateGreaterThan(): bool
    {
        if ($this->options['min'] !== null) {
            if ($this->options['inclusive'] === false && $this->value <= $this->options['min']) {
                $this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_THAN_MIN);
                return false;
            }

            if ($this->value < $this->options['min']) {
                $this->setError(self::VALIDATOR_ERROR_NUMBER_MUST_BE_HIGHER_OR_EQUAL_TO_MIN);
                return false;
            }
        }
        return true;
    }
429310
protected function installCliStep3()
    {
        $this->data['step'] = 3;
        $result = $this->installFinish($this->data, $this->db);

        if ($result['severity'] !== 'success') {
            throw new UnexpectedValueException($result['message']);
        }
    }