Creates an exception for an unsupported language string.
public static forLanguage ( string $language, Exception $cause = null ) : static | ||
$language | string | The unsupported language. |
$cause | Exception | The exception that caused this exception. |
return | static | The created exception. |
/** * {@inheritdoc} */ public function unbind($query, $typeName = null, array $parameterValues = null, $language = null) { if (null !== $language && 'glob' !== $language) { throw UnsupportedLanguageException::forLanguage($language); } if (null !== $typeName) { $this->removeBindingsByQueryAndType($query, $typeName, $parameterValues); return; } $this->removeBindingsByQuery($query, $parameterValues); }
/** * Validate a language is usable to search in repositories. * * @param string $language */ protected function failUnlessGlob($language) { if ('glob' !== $language) { throw UnsupportedLanguageException::forLanguage($language); } }
/** * {@inheritdoc} */ public function contains($query, $language = 'glob') { if ('glob' !== $language) { throw UnsupportedLanguageException::forLanguage($language); } Assert::stringNotEmpty($query, 'The glob must be a non-empty string. Got: %s'); Assert::startsWith($query, '/', 'The glob %s is not absolute.'); $query = Path::canonicalize($query); if (false !== strpos($query, '*')) { $iterator = $this->getGlobIterator($query); $iterator->rewind(); return $iterator->valid(); } return isset($this->resources[$query]); }
private function getGlobIterator($query, $language) { if ('glob' !== $language) { throw UnsupportedLanguageException::forLanguage($language); } Assert::stringNotEmpty($query, 'The glob must be a non-empty string. Got: %s'); Assert::startsWith($query, '/', 'The glob %s is not absolute.'); $query = Path::canonicalize($query); return new GlobIterator($this->baseDir . $query); }