protected function ClassLoaderTest::replaceWildcard in X Autoload 7.4
Same name and namespace in other branches
- 7.5 tests/src/ClassLoaderTest.php \Drupal\xautoload\Tests\ClassLoaderTest::replaceWildcard()
Parameters
string $str:
string $replacement:
Return value
string
Throws
\Exception
2 calls to ClassLoaderTest::replaceWildcard()
- ClassLoaderTest::assertCandidateOrder in tests/
lib/ ClassLoaderTest.php - ClassLoaderTest::replaceWildcardMultiple in tests/
lib/ ClassLoaderTest.php
File
- tests/
lib/ ClassLoaderTest.php, line 191
Class
Namespace
Drupal\xautoload\TestsCode
protected function replaceWildcard($str, $replacement) {
$fragments = explode('%', $str);
if (count($fragments) < 2) {
throw new \Exception("String '{$str}' does not contain a '%' wildcard.");
}
if (count($fragments) > 2) {
throw new \Exception("String '{$str}' has more than one '%' wildcard.");
}
return str_replace('%', $replacement, $str);
}