diff options
author | Andrew Dolgov <[email protected]> | 2023-10-27 22:07:28 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2023-10-27 22:07:28 +0300 |
commit | 5920ac814c0a72b8c348650b09597ed8793a54c9 (patch) | |
tree | a52a8f755ea033a6c96f8a1c1633d81b68ab5c45 /classes/Config.php | |
parent | 8c9c69921f8552e49291df9e2503709aaa564270 (diff) |
replace some dirname horrors with a separate unit-tested method
Diffstat (limited to 'classes/Config.php')
-rw-r--r-- | classes/Config.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/classes/Config.php b/classes/Config.php index 2c2cd4d65..e6e19ba09 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -319,7 +319,7 @@ class Config { * @return array<string, mixed>|string */ private function _get_version(bool $as_string = true) { - $root_dir = dirname(__DIR__); + $root_dir = self::get_self_dir(); if (empty($this->version)) { $this->version["status"] = -1; @@ -413,7 +413,7 @@ class Config { private function _get_migrations() : Db_Migrations { if (empty($this->migrations)) { $this->migrations = new Db_Migrations(); - $this->migrations->initialize(dirname(__DIR__) . "/sql", "ttrss_version", true, self::SCHEMA_VERSION); + $this->migrations->initialize(self::get_self_dir() . "/sql", "ttrss_version", true, self::SCHEMA_VERSION); } return $this->migrations; @@ -703,4 +703,9 @@ class Config { static function get_user_agent(): string { return sprintf(self::get(self::HTTP_USER_AGENT), self::get_version()); } + + static function get_self_dir() : string { + return dirname(__DIR__); # we're in classes/Config.php + } + } |