Skip to content

Commit

Permalink
Update FtpAdapter.php, remove goto statement
Browse files Browse the repository at this point in the history
The goto statement can make the code's flow difficult to follow. PHP code is typically expected to have a more linear and understandable structure. For example, when using goto, it can jump from one part of the code to another in a non - sequential manner. This can lead to confusion for developers who are trying to understand the program's logic, especially in larger codebases.
  • Loading branch information
ywisax authored Dec 19, 2024
1 parent 704c10b commit 96cde4b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Ftp/FtpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@ public function __destruct()
*/
private function connection()
{
start:
if ( ! $this->hasFtpConnection()) {
$this->connection = $this->connectionProvider->createConnection($this->connectionOptions);
$this->rootDirectory = $this->resolveConnectionRoot($this->connection);
$this->prefixer = new PathPrefixer($this->rootDirectory);
while (true) {
if ( ! $this->hasFtpConnection()) {
$this->connection = $this->connectionProvider->createConnection($this->connectionOptions);
$this->rootDirectory = $this->resolveConnectionRoot($this->connection);
$this->prefixer = new PathPrefixer($this->rootDirectory);

return $this->connection;
}
return $this->connection;
}

if ($this->connectivityChecker->isConnected($this->connection) === false) {
$this->connection = false;
goto start;
if ($this->connectivityChecker->isConnected($this->connection) === false) {
$this->connection = false;
continue;
}
break;
}

ftp_chdir($this->connection, $this->rootDirectory);
Expand Down

0 comments on commit 96cde4b

Please sign in to comment.