diff --git a/index.php b/index.php index 09f42a37..1b66ff5c 100644 --- a/index.php +++ b/index.php @@ -63,7 +63,7 @@ try { $list->bridges = array(); $list->total = 0; - foreach(Bridge::listBridges() as $bridgeName) { + foreach(Bridge::getBridgeNames() as $bridgeName) { $bridge = Bridge::create($bridgeName); diff --git a/lib/Bridge.php b/lib/Bridge.php index 6a09b306..c9561c8f 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -154,29 +154,29 @@ class Bridge { } /** - * Returns the list of bridge names based on the working directory. + * Returns the list of bridge names from the working directory. * * The list is cached internally to allow for successive calls. * * @return array List of bridge names */ - public static function listBridges(){ + public static function getBridgeNames(){ - static $listBridge = array(); // Initialized on first call + static $bridgeNames = array(); // Initialized on first call - if(empty($listBridge)) { - $dirFiles = scandir(self::getWorkingDir()); + if(empty($bridgeNames)) { + $files = scandir(self::getWorkingDir()); - if($dirFiles !== false) { - foreach($dirFiles as $fileName) { - if(preg_match('/^([^.]+)Bridge\.php$/U', $fileName, $out)) { - $listBridge[] = $out[1]; + if($files !== false) { + foreach($files as $file) { + if(preg_match('/^([^.]+)Bridge\.php$/U', $file, $out)) { + $bridgeNames[] = $out[1]; } } } } - return $listBridge; + return $bridgeNames; } /** @@ -218,7 +218,7 @@ class Bridge { $contents = trim(file_get_contents(WHITELIST)); if($contents === '*') { // Whitelist all bridges - self::$whitelist = self::listBridges(); + self::$whitelist = self::getBridgeNames(); } else { self::$whitelist = array_map('self::sanitizeBridgeName', explode("\n", $contents)); } @@ -281,9 +281,9 @@ class Bridge { } // The name is valid if a corresponding bridge file is found on disk - if(in_array(strtolower($name), array_map('strtolower', self::listBridges()))) { - $index = array_search(strtolower($name), array_map('strtolower', self::listBridges())); - return self::listBridges()[$index]; + if(in_array(strtolower($name), array_map('strtolower', self::getBridgeNames()))) { + $index = array_search(strtolower($name), array_map('strtolower', self::getBridgeNames())); + return self::getBridgeNames()[$index]; } Debug::log('Invalid bridge name specified: "' . $name . '"!'); diff --git a/lib/BridgeList.php b/lib/BridgeList.php index 4a612a4e..0bfc657c 100644 --- a/lib/BridgeList.php +++ b/lib/BridgeList.php @@ -28,7 +28,7 @@ EOD; $totalActiveBridges = 0; $inactiveBridges = ''; - $bridgeList = Bridge::listBridges(); + $bridgeList = Bridge::getBridgeNames(); $formats = Format::searchInformation(); $totalBridges = count($bridgeList); diff --git a/tests/BridgeImplementationTest.php b/tests/BridgeImplementationTest.php index 0261f58c..690a6189 100644 --- a/tests/BridgeImplementationTest.php +++ b/tests/BridgeImplementationTest.php @@ -141,7 +141,7 @@ final class BridgeImplementationTest extends TestCase { } public function count() { - return count(Bridge::listBridges()); + return count(Bridge::getBridgeNames()); } public function run(TestResult $result = null) { @@ -150,7 +150,7 @@ final class BridgeImplementationTest extends TestCase { $result = new TestResult; } - foreach (Bridge::listBridges() as $bridge) { + foreach (Bridge::getBridgeNames() as $bridge) { $bridge .= 'Bridge';