Skip to content

Commit bbd0c2e

Browse files
committed
Adding required information directory to the FileSystemException static methods
1 parent 71fb324 commit bbd0c2e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Exceptions/FileSystemException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ function __construct(string $message, int $code = 0)
88
{
99
parent::__construct($message, $code);
1010
}
11-
public static function folderNotExist(): self
11+
public static function folderNotExist(string $directory): self
1212
{
13-
return new self("The folder does not exist or the script does not have read access", 404);
13+
return new self(sprintf("This folder: \"%s\", does not exist or the script does not have read access", $directory), 404);
1414
}
15-
public static function createForbidden(): self
15+
public static function createForbidden(string $directory): self
1616
{
17-
return new self("This folder cannot be created due to a permissions error", 403);
17+
return new self(sprintf("This folder: \"%s\", cannot be created due to a permissions error", $directory), 403);
1818
}
1919
public function isErrorFolderNotExist(): bool
2020
{

src/Helpers/FileSystem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class FileSystem
1313
public function findFile(string $directory, string $fileName, ?string $extension = null): string|null
1414
{
1515
if ($this->is_dir($directory)) return $this->recursiveSearchNameFileCaseInsensitive($directory, $fileName, $extension, 0);
16-
else throw FileSystemException::folderNotExist();
16+
else throw FileSystemException::folderNotExist($directory);
1717
}
1818
/**
1919
* @return string[]
@@ -22,7 +22,7 @@ public function findFile(string $directory, string $fileName, ?string $extension
2222
public function findFiles(string $directory, ?string $extension = null, int $level = 1): array
2323
{
2424
if ($this->is_dir($directory)) return $this->recursiveSearchFiles($directory, $extension, $level);
25-
else throw FileSystemException::folderNotExist();
25+
else throw FileSystemException::folderNotExist($directory);
2626
}
2727
/** @param string|string[] $folders */
2828
public function findFolder(string|array $folders): bool
@@ -64,7 +64,7 @@ public function is_dir(string &$directory): bool
6464
/** @throws FileSystemException */
6565
public static function mkdir(string $directory): void
6666
{
67-
mkdir($directory, 0755, true) ?: throw FileSystemException::createForbidden();
67+
mkdir($directory, 0755, true) ?: throw FileSystemException::createForbidden($directory);
6868
}
6969
public function recursiveSearchNameFileCaseInsensitive(string $directory, string $fileName, ?string $extension = null, int $level = -1): string|null
7070
{

0 commit comments

Comments
 (0)