This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
6
{
7
private $path;
8
9
22
public function __construct(string $path)
10
{
11
22
if (!is_dir($path)) {
12
1
throw new NotFoundException(sprintf('The directory `%s` does not exist.', $path));
13
}
14
15
21
$this->path = $path;
16
21
}
17
18
17
public static function create(string $path, int $permissions = 0770): Directory
19
{
20
17
if (is_dir($path)) {
21
1
throw new ExistsException(sprintf('The directory `%s` already exists.', $path));
22
}
23
24
16
@mkdir($path, $permissions, true);
25
26
16
if (!is_dir($path)) {
27
throw new PermissionDeniedException(error_get_last()['message'], error_get_last()['type']);
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.