|
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.9.9 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Quantum\App\Exceptions; |
|
16
|
|
|
|
|
17
|
|
|
use Quantum\App\Enums\ExceptionMessages; |
|
18
|
|
|
use Exception; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class BaseException |
|
22
|
|
|
* @package Quantum\App |
|
23
|
|
|
*/ |
|
24
|
|
|
class BaseException extends Exception |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param string $methodName |
|
29
|
|
|
* @param string $className |
|
30
|
|
|
* @return self |
|
31
|
|
|
*/ |
|
32
|
|
|
public static function methodNotSupported(string $methodName, string $className): self |
|
33
|
|
|
{ |
|
34
|
|
|
return new static( |
|
35
|
|
|
_message(ExceptionMessages::METHOD_NOT_SUPPORTED, [$methodName, $className]), |
|
36
|
|
|
E_WARNING |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param string $name |
|
42
|
|
|
* @return self |
|
43
|
|
|
*/ |
|
44
|
|
|
public static function adapterNotSupported(string $name): self |
|
45
|
|
|
{ |
|
46
|
|
|
return new static( |
|
47
|
|
|
_message(ExceptionMessages::ADAPTER_NOT_SUPPORTED, [$name]), |
|
48
|
|
|
E_ERROR |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param string $name |
|
54
|
|
|
* @return self |
|
55
|
|
|
*/ |
|
56
|
|
|
public static function driverNotSupported(string $name): self |
|
57
|
|
|
{ |
|
58
|
|
|
return new static( |
|
59
|
|
|
_message(ExceptionMessages::DRIVER_NOT_SUPPORTED, [$name]), |
|
60
|
|
|
E_ERROR |
|
61
|
|
|
); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param string $name |
|
66
|
|
|
* @return self |
|
67
|
|
|
*/ |
|
68
|
|
|
public static function fileNotFound(string $name): self |
|
69
|
|
|
{ |
|
70
|
|
|
return new static( |
|
71
|
|
|
_message(ExceptionMessages::FILE_NOT_FOUND, [$name]), |
|
72
|
|
|
E_ERROR |
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @param string $subject |
|
78
|
|
|
* @param string $name |
|
79
|
|
|
* @return self |
|
80
|
|
|
*/ |
|
81
|
|
|
public static function notFound(string $subject, string $name): self |
|
82
|
|
|
{ |
|
83
|
|
|
return new static( |
|
84
|
|
|
_message(ExceptionMessages::NOT_FOUND, [$subject, $name]), |
|
85
|
|
|
E_ERROR |
|
86
|
|
|
); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param string $instance |
|
91
|
|
|
* @param string $name |
|
92
|
|
|
* @return self |
|
93
|
|
|
*/ |
|
94
|
|
|
public static function notInstanceOf(string $instance, string $name): self |
|
95
|
|
|
{ |
|
96
|
|
|
return new static( |
|
97
|
|
|
_message(ExceptionMessages::NOT_INSTANCE_OF, [$instance, $name]), |
|
98
|
|
|
E_ERROR |
|
99
|
|
|
); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param string $name |
|
104
|
|
|
* @return self |
|
105
|
|
|
*/ |
|
106
|
|
|
public static function cantConnect(string $name): self |
|
107
|
|
|
{ |
|
108
|
|
|
return new static( |
|
109
|
|
|
_message(ExceptionMessages::CANT_CONNECT, [$name]), |
|
110
|
|
|
E_ERROR |
|
111
|
|
|
); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param string $name |
|
116
|
|
|
* @return self |
|
117
|
|
|
*/ |
|
118
|
|
|
|
|
119
|
|
|
public static function missingConfig(string $name): self |
|
120
|
|
|
{ |
|
121
|
|
|
return new static( |
|
122
|
|
|
_message(ExceptionMessages::MISSING_CONFIG, $name), |
|
123
|
|
|
E_ERROR |
|
124
|
|
|
); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @param string $name |
|
129
|
|
|
* @return self |
|
130
|
|
|
*/ |
|
131
|
|
|
public static function requestMethodNotAvailable(string $name): self |
|
132
|
|
|
{ |
|
133
|
|
|
return new static( |
|
134
|
|
|
_message(ExceptionMessages::UNAVAILABLE_REQUEST_METHOD, [$name]), |
|
135
|
|
|
E_WARNING |
|
136
|
|
|
); |
|
137
|
|
|
} |
|
138
|
|
|
} |