mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 17:45:40 +03:00
bridge: Rename listBridge to getBridgeNames
This commit is contained in:
parent
66b11b8c41
commit
88b0656954
4 changed files with 18 additions and 18 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 . '"!');
|
||||
|
|
|
@ -28,7 +28,7 @@ EOD;
|
|||
$totalActiveBridges = 0;
|
||||
$inactiveBridges = '';
|
||||
|
||||
$bridgeList = Bridge::listBridges();
|
||||
$bridgeList = Bridge::getBridgeNames();
|
||||
$formats = Format::searchInformation();
|
||||
|
||||
$totalBridges = count($bridgeList);
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
Loading…
Reference in a new issue