You are here

protected function ClassLoaderTest::replaceWildcard in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 tests/lib/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/src/ClassLoaderTest.php
ClassLoaderTest::replaceWildcardMultiple in tests/src/ClassLoaderTest.php

File

tests/src/ClassLoaderTest.php, line 200

Class

ClassLoaderTest

Namespace

Drupal\xautoload\Tests

Code

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);
}