Asserts that the filesystem connection is valid, throws an exception if not.

@param  mixed $disk A filesystem connection identifier.
@throws InvalidArgumentException If the filesystem is not a string or NULL.
@return void
771043
protected function assertValidDisk($disk)
    {
        $translator = $this->translator();

        if ($disk === null) {
            $message = $translator->translate(
                'Default filesystem [{{ defaultFilesystemConnection }}] is not defined',
                [
                    '{{ defaultFilesystemConnection }}' => 'config.filesystem.default_connection'
                ]
            );

            throw new InvalidArgumentException($message, 400);
        }

        if (!is_string($disk)) {
            $actualType = is_object($disk) ? get_class($disk) : gettype($disk);
            $message = $translator->translate(
                '{{ parameter }} must be a {{ expectedType }}, received {{ actualType }}',
                [
                    '{{ parameter }}'    => '"disk"',
                    '{{ expectedType }}' => 'string',
                    '{{ actualType }}'   => $actualType,
                ]
            );

            throw new InvalidArgumentException($message, 400);
        }

        if (!isset($this->filesystems[$disk])) {
            $message = $translator->translate('Filesystem identifier "{{ fsIdent }}" is not defined.', [
                '{{ fsIdent }}' => $disk
            ]);

            throw new InvalidArgumentException($message, 400);
        }
    }
341129
public function validate($str)
    {
        if ($str === null) {
            throw new \InvalidArgumentException('Error: String must not be null');
        }
        if (! is_string($str)) {
            throw new \InvalidArgumentException(
                'Error: String must be of type string but is of type "'.gettype($str).'"'
            );
        }
        if ($str === '') {
            throw new \InvalidArgumentException('Error: String must not be empty');
        }
        if ($this->containsMultibyteChar($str)) {
            throw new \InvalidArgumentException('Error: String must not contain any multibyte characters');
        }
    }
1019510
public function setConst(string $const): void
	{
		if (!$this->locale) {
			throw new InvalidArgumentException('Locale must be set before calling setConst');
		}
		if (Strings::match($const, '/[^A-Za-z0-9_]/')) {
			throw new InvalidArgumentException('Constant contains invalid characters');
		}

		/* @var $repository ContentRepository */
		$repository = $this->getRepository();
		$content = $repository->getByConst($const, $this->locale->name);
		if ($content !== null && $content !== $this) {
			throw new UniqueConstraintViolationException("Content with '$const' exists");
		}
		$this->const = $const;
	}
1315867
public function checkIsEntity($object)
    {
        if (!$object instanceof $this->entityName) {
            throw InvalidArgumentException::invalidEntityType(
                $this->getEntityName(),
                $object
            );
        }
    }
613590
protected function checkTable(string $table)
    {
        if (! property_exists($this, $table) || ! $this->$table instanceof Table) {
            throw new \InvalidArgumentException("Invalid table name: `{$table}`.");
        }
    }
869021
public static function reset($object)
	{
		if (!($object instanceof CodeGeneratorResponse)) {
			throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse.');
		}
		$object->error = NULL;
		$object->file = NULL;
	}
63977
public function protect($key) {
        if (!is_string($key)) {
            throw new \Calf\Exception\InvalidArgument('Key must be string.');
        }

        if (!isset($this->_keys[$key])) {
            throw new \Calf\Exception\Runtime('Key doesn\'t exists: ' . $key);
        }

        $this->_protected[$key] = true;
    }
407082
protected function validateServerConfig($config)
    {
        if (!is_array($config)) {
            throw new InvalidArgumentException($this->translate(
                'Server configuration should be an array or Traversable.'
            ));
        }
        if (!isset($config['id']) || empty($config['id'])) {
            throw new InvalidArgumentException($this->translate(
                'Cannot find server id in configuration.'
            ));
        }
        if (!isset($config['connection']) || empty($config['connection'])) {
            throw new InvalidArgumentException($this->translate(
                'Cannot find connection type in configuration.'
            ));
        }
    }
155277
protected function assertValidPath($path)
    {
        $translator = $this->translator();

        if (empty($path) && !is_numeric($path)) {
            $message = $translator->translate(
                '{{ parameter }} required and must be a {{ expectedType }}',
                [
                    '{{ parameter }}'    => '"path"',
                    '{{ expectedType }}' => 'string',
                ]
            );

            throw new InvalidArgumentException($message, 400);
        } elseif (!is_string($path)) {
            $actualType = is_object($path) ? get_class($path) : gettype($path);
            $message = $translator->translate(
                '{{ parameter }} must be a {{ expectedType }}, received {{ actualType }}',
                [
                    '{{ parameter }}'    => '"path"',
                    '{{ expectedType }}' => 'string',
                    '{{ actualType }}'   => $actualType,
                ]
            );

            throw new InvalidArgumentException($message, 400);
        }
    }
379815
public function setFileSystem($fileSystem)
    {
        if (! is_object($fileSystem) || ! is_a($fileSystem, 'Symfony\Component\Filesystem\Filesystem')) {
            throw new \InvalidArgumentException(
                'The File System was not a valid object.'
            );
        }
        $this->fileSystem = $fileSystem;
    }
1212728
protected function connect()
    {
        // Already connected
        if ($this->database !== null) {
            return;
        }

        $connection = $this->resolver
            ->connection($this->config('connection'));

        if ($connection->getDriverName() !== 'pgsql') {
            throw new \InvalidArgumentException('Connection should use pgsql driver.');
        }

        $this->database = $connection;
    }
338024
private function validateString(string $uri): void
    {
        if (!\is_string($uri)) {
            throw new InvalidArgumentException(sprintf('String required, %s given', \gettype($uri)));
        }
    }
130744
private function assertValidField(string $field) : void
    {
        if (! isset($this->entityChangeSet[$field])) {
            throw new InvalidArgumentException(sprintf(
                'Field "%s" is not a valid field of the entity "%s" in PreUpdateEventArgs.',
                $field,
                get_class($this->getObject())
            ));
        }
    }
58952
public function delete($key)
    {
        /* If $key is not valid string throws InvalidArgumentException */
        if (!$this->isString($key)) {
            throw new InvalidArgumentException('Cache key must be not empty string');
        }

        $path = sha1($key);

        if ($this->filesystem()->has($path)) {
            $this->filesystem()->delete($path);
            return true;
        }
        return false;
    }
678501
public static function validateKey($key): void
    {
        if (!is_string($key)) {
            throw new InvalidArgumentException(sprintf(
                'Cache key must be string, "%s" given',
                is_object($key) ? get_class($key) : gettype($key)
            ));
        }
        if (!isset($key[0])) {
            throw new InvalidArgumentException('Cache key length must be greater than zero');
        }
        if (isset($key[strcspn($key, '{}()/\@:')])) {
            throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters {}()/\@:', $key));
        }
    }
489785
protected function assertFileIsReadable(string $fileName): void
    {
        if (!is_file($fileName) || !is_readable($fileName)) {
            throw new InvalidPathException(sprintf('Unable to read the file at %s', $fileName));
        }
    }
1243026
private function validateKey($key)
    {
        $details = openssl_pkey_get_details($key);

        if (!isset($details['key']) || $details['type'] !== OPENSSL_KEYTYPE_RSA) {
            throw new \InvalidArgumentException('This key is not compatible with RSA signatures');
        }
    }