From 04edbf87609877fbd1eaa75ed363d21986941f6a Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Fri, 13 Dec 2024 19:01:06 +0000 Subject: [PATCH] refactor: change method name --- src/Storage/Service/FTPService.php | 15 ++++++--------- tests/Filesystem/FTPServiceTest.php | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Storage/Service/FTPService.php b/src/Storage/Service/FTPService.php index 9b45c3db..c0f79790 100644 --- a/src/Storage/Service/FTPService.php +++ b/src/Storage/Service/FTPService.php @@ -111,7 +111,7 @@ public function connect() $this->connection = $connection; $this->login(); - $this->setConnectionRoot(); + $this->changePath(); $this->setConnectionPassiveMode(); } @@ -165,21 +165,18 @@ private function login(): bool } /** - * Set the connection root. + * Change path. * * @param string $path * @return void */ - public function setConnectionRoot(string $path = '') + public function changePath(?string $path = null) { $base_path = $path ?: $this->config['root']; if ($base_path && (!@ftp_chdir($this->connection, $base_path))) { throw new RuntimeException('Root is invalid or does not exist: ' . $base_path); } - - // Store absolute path for further reference. - ftp_pwd($this->connection); } /** @@ -359,13 +356,13 @@ public function makeDirectory(string $dirname, int $mode = 0777): bool foreach ($directories as $directory) { if (false === $this->makeActualDirectory($directory)) { - $this->setConnectionRoot(); + $this->changePath(); return false; } ftp_chdir($connection, $directory); } - $this->setConnectionRoot(); + $this->changePath(); return true; } @@ -567,7 +564,7 @@ protected function listDirectoryContents($directory = '.') $listing = @ftp_rawlist($this->getConnection(), '.') ?: []; - $this->setConnectionRoot(); + $this->changePath(); return $this->normalizeDirectoryListing($listing); } diff --git a/tests/Filesystem/FTPServiceTest.php b/tests/Filesystem/FTPServiceTest.php index c12b74fe..4a26f007 100644 --- a/tests/Filesystem/FTPServiceTest.php +++ b/tests/Filesystem/FTPServiceTest.php @@ -27,7 +27,7 @@ protected function setUp(): void protected function tearDown(): void { - $this->ftp_service->setConnectionRoot(); + $this->ftp_service->changePath(); } public function test_the_connection()