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->bridges = array();
|
||||||
$list->total = 0;
|
$list->total = 0;
|
||||||
|
|
||||||
foreach(Bridge::listBridges() as $bridgeName) {
|
foreach(Bridge::getBridgeNames() as $bridgeName) {
|
||||||
|
|
||||||
$bridge = Bridge::create($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.
|
* The list is cached internally to allow for successive calls.
|
||||||
*
|
*
|
||||||
* @return array List of bridge names
|
* @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)) {
|
if(empty($bridgeNames)) {
|
||||||
$dirFiles = scandir(self::getWorkingDir());
|
$files = scandir(self::getWorkingDir());
|
||||||
|
|
||||||
if($dirFiles !== false) {
|
if($files !== false) {
|
||||||
foreach($dirFiles as $fileName) {
|
foreach($files as $file) {
|
||||||
if(preg_match('/^([^.]+)Bridge\.php$/U', $fileName, $out)) {
|
if(preg_match('/^([^.]+)Bridge\.php$/U', $file, $out)) {
|
||||||
$listBridge[] = $out[1];
|
$bridgeNames[] = $out[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $listBridge;
|
return $bridgeNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,7 +218,7 @@ class Bridge {
|
||||||
$contents = trim(file_get_contents(WHITELIST));
|
$contents = trim(file_get_contents(WHITELIST));
|
||||||
|
|
||||||
if($contents === '*') { // Whitelist all bridges
|
if($contents === '*') { // Whitelist all bridges
|
||||||
self::$whitelist = self::listBridges();
|
self::$whitelist = self::getBridgeNames();
|
||||||
} else {
|
} else {
|
||||||
self::$whitelist = array_map('self::sanitizeBridgeName', explode("\n", $contents));
|
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
|
// The name is valid if a corresponding bridge file is found on disk
|
||||||
if(in_array(strtolower($name), array_map('strtolower', self::listBridges()))) {
|
if(in_array(strtolower($name), array_map('strtolower', self::getBridgeNames()))) {
|
||||||
$index = array_search(strtolower($name), array_map('strtolower', self::listBridges()));
|
$index = array_search(strtolower($name), array_map('strtolower', self::getBridgeNames()));
|
||||||
return self::listBridges()[$index];
|
return self::getBridgeNames()[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log('Invalid bridge name specified: "' . $name . '"!');
|
Debug::log('Invalid bridge name specified: "' . $name . '"!');
|
||||||
|
|
|
@ -28,7 +28,7 @@ EOD;
|
||||||
$totalActiveBridges = 0;
|
$totalActiveBridges = 0;
|
||||||
$inactiveBridges = '';
|
$inactiveBridges = '';
|
||||||
|
|
||||||
$bridgeList = Bridge::listBridges();
|
$bridgeList = Bridge::getBridgeNames();
|
||||||
$formats = Format::searchInformation();
|
$formats = Format::searchInformation();
|
||||||
|
|
||||||
$totalBridges = count($bridgeList);
|
$totalBridges = count($bridgeList);
|
||||||
|
|
|
@ -141,7 +141,7 @@ final class BridgeImplementationTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function count() {
|
public function count() {
|
||||||
return count(Bridge::listBridges());
|
return count(Bridge::getBridgeNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run(TestResult $result = null) {
|
public function run(TestResult $result = null) {
|
||||||
|
@ -150,7 +150,7 @@ final class BridgeImplementationTest extends TestCase {
|
||||||
$result = new TestResult;
|
$result = new TestResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Bridge::listBridges() as $bridge) {
|
foreach (Bridge::getBridgeNames() as $bridge) {
|
||||||
|
|
||||||
$bridge .= 'Bridge';
|
$bridge .= 'Bridge';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue