1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Quantum PHP Framework |
5
|
|
|
* |
6
|
|
|
* An open source software development framework for PHP |
7
|
|
|
* |
8
|
|
|
* @package Quantum |
9
|
|
|
* @author Arman Ag. <[email protected]> |
10
|
|
|
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) |
11
|
|
|
* @link http://quantum.softberg.org/ |
12
|
|
|
* @since 2.6.0 |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Quantum\Exceptions; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class FileSystemException |
19
|
|
|
* @package Quantum\Exceptions |
20
|
|
|
*/ |
21
|
|
|
class FileSystemException extends \Exception |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Method not supported message |
26
|
|
|
*/ |
27
|
|
|
const NOT_SUPPORTED_METHOD = 'The method `{%1}` is not supported on current `{%2}` adapter'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Directory does not exists message |
31
|
|
|
*/ |
32
|
|
|
const DIRECTORY_NOT_EXIST = 'Directory `{%1}` does not exists'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Directory is not writable message |
36
|
|
|
*/ |
37
|
|
|
const DIRECTORY_NOT_WRITABLE = 'Directory `{%1}` not writable'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Directory can not be created message |
41
|
|
|
*/ |
42
|
|
|
const DIRECTORY_CANT_BE_CREATED = 'Directory `{%1}` could not be created'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* File already exists message |
46
|
|
|
*/ |
47
|
|
|
const FILE_ALREADY_EXISTS = 'File already exists'; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param string $methodName |
51
|
|
|
* @param string $adapterName |
52
|
|
|
* @return \Quantum\Exceptions\FileSystemException |
53
|
|
|
*/ |
54
|
|
|
public static function methodNotSupported(string $methodName, string $adapterName): FileSystemException |
55
|
|
|
{ |
56
|
|
|
return new static(_message(self::NOT_SUPPORTED_METHOD, [$methodName, $adapterName]), E_WARNING); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param string $name |
61
|
|
|
* @return \Quantum\Exceptions\FileSystemException |
62
|
|
|
*/ |
63
|
|
|
public static function directoryNotExists(string $name): FileSystemException |
64
|
|
|
{ |
65
|
|
|
return new static(_message(self::DIRECTORY_NOT_EXIST, $name), E_WARNING); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param string $name |
70
|
|
|
* @return \Quantum\Exceptions\FileSystemException |
71
|
|
|
*/ |
72
|
|
|
public static function directoryNotWritable(string $name): FileSystemException |
73
|
|
|
{ |
74
|
|
|
return new static(_message(self::DIRECTORY_NOT_WRITABLE, $name), E_WARNING); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @return \Quantum\Exceptions\FileSystemException |
79
|
|
|
*/ |
80
|
|
|
public static function fileAlreadyExists(): FileSystemException |
81
|
|
|
{ |
82
|
|
|
return new static(self::FILE_ALREADY_EXISTS, E_WARNING); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
} |
86
|
|
|
|