From 4a99c6e630ded11160fcec8fe3b1a751b238cf8e Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 14 Nov 2018 20:39:39 +0100 Subject: [PATCH] cache: Rename setDir and getDir - Rename setDir to setWorkingDir - Rename getDir to getWorkingDir - Rename parameter $workingDir to $dir in getWorkingDir --- lib/Cache.php | 26 +++++++++++++------------- lib/rssbridge.php | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Cache.php b/lib/Cache.php index a70c991c..6545a773 100644 --- a/lib/Cache.php +++ b/lib/Cache.php @@ -26,7 +26,7 @@ * require_once __DIR__ . '/rssbridge.php'; * * // Step 1: Set the working directory - * Cache::setDir(__DIR__ . '/../caches/'); + * Cache::setWorkingDir(__DIR__ . '/../caches/'); * * // Step 2: Create a new instance of a cache object (based on the name) * $cache = Cache::create('FileCache'); @@ -38,7 +38,7 @@ class Cache { * Holds a path to the working directory. * * Do not access this property directly! - * Use {@see Cache::setDir()} and {@see Cache::getDir()} instead. + * Use {@see Cache::setWorkingDir()} and {@see Cache::getWorkingDir()} instead. * * @var string|null */ @@ -69,7 +69,7 @@ class Cache { throw new \InvalidArgumentException('Cache name invalid!'); } - $filePath = self::getDir() . $name . '.php'; + $filePath = self::getWorkingDir() . $name . '.php'; if(!file_exists($filePath)) { throw new \Exception('Cache file ' . $filePath . ' does not exist!'); @@ -83,38 +83,38 @@ class Cache { /** * Sets the working directory. * - * @param string $workingDir Path to a directory containing cache classes - * @throws \InvalidArgumentException if $workingDir is not a string. + * @param string $dir Path to a directory containing cache classes + * @throws \InvalidArgumentException if $dir is not a string. * @throws \Exception if the working directory doesn't exist. - * @throws \InvalidArgumentException if $workingDir is not a directory. + * @throws \InvalidArgumentException if $dir is not a directory. * @return void */ - public static function setDir($workingDir){ + public static function setWorkingDir($dir){ self::$workingDir = null; - if(!is_string($workingDir)) { + if(!is_string($dir)) { throw new \InvalidArgumentException('Working directory is not a valid string!'); } - if(!file_exists($workingDir)) { + if(!file_exists($dir)) { throw new \Exception('Working directory does not exist!'); } - if(!is_dir($workingDir)) { + if(!is_dir($dir)) { throw new \InvalidArgumentException('Working directory is not a directory!'); } - self::$workingDir = realpath($workingDir) . '/'; + self::$workingDir = realpath($dir) . '/'; } /** * Returns the current working directory. - * The working directory must be set with {@see Cache::setDir()}! + * The working directory must be set with {@see Cache::setWorkingDir()}! * * @throws \LogicException if the working directory is not set. * @return string The current working directory. */ - public static function getDir(){ + public static function getWorkingDir(){ if(is_null(self::$workingDir)) { throw new \LogicException('Working directory is not set!'); } diff --git a/lib/rssbridge.php b/lib/rssbridge.php index 07812f2c..16315eec 100644 --- a/lib/rssbridge.php +++ b/lib/rssbridge.php @@ -43,7 +43,7 @@ require_once PATH_LIB_VENDOR . 'php-urljoin/src/urljoin.php'; try { Bridge::setDir(PATH_LIB_BRIDGES); Format::setDir(PATH_LIB_FORMATS); - Cache::setDir(PATH_LIB_CACHES); + Cache::setWorkingDir(PATH_LIB_CACHES); } catch(Exception $e) { error_log($e); header('Content-type: text/plain', true, 500);