1
|
|
|
<?php namespace Arcanedev\LaravelTracker\Exceptions; |
2
|
|
|
|
3
|
|
|
use Illuminate\Support\Arr; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class ExceptionFactory |
7
|
|
|
* |
8
|
|
|
* @package Arcanedev\LaravelTracker\Exceptions |
9
|
|
|
* @author ARCANEDEV <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class ExceptionFactory |
12
|
|
|
{ |
13
|
|
|
/* ------------------------------------------------------------------------------------------------ |
14
|
|
|
| Properties |
15
|
|
|
| ------------------------------------------------------------------------------------------------ |
16
|
|
|
*/ |
17
|
|
|
/** |
18
|
|
|
* Supported exceptions. |
19
|
|
|
* |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
protected static $supported = [ |
23
|
|
|
E_ERROR => Errors\Error::class, |
24
|
|
|
E_WARNING => Errors\Warning::class, |
25
|
|
|
E_PARSE => Errors\Parse::class, |
26
|
|
|
E_NOTICE => Errors\Notice::class, |
27
|
|
|
E_CORE_ERROR => Errors\CoreError::class, |
28
|
|
|
E_CORE_WARNING => Errors\CoreWarning::class, |
29
|
|
|
E_COMPILE_ERROR => Errors\CompileError::class, |
30
|
|
|
E_COMPILE_WARNING => Errors\CompileWarning::class, |
31
|
|
|
E_USER_ERROR => Errors\UserError::class, |
32
|
|
|
E_USER_WARNING => Errors\UserWarning::class, |
33
|
|
|
E_USER_NOTICE => Errors\UserNotice::class, |
34
|
|
|
E_STRICT => Errors\Strict::class, |
35
|
|
|
E_RECOVERABLE_ERROR => Errors\RecoverableError::class, |
36
|
|
|
E_DEPRECATED => Errors\Deprecated::class, |
37
|
|
|
E_USER_DEPRECATED => Errors\UserDeprecated::class, |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
/* ------------------------------------------------------------------------------------------------ |
41
|
|
|
| Main Functions |
42
|
|
|
| ------------------------------------------------------------------------------------------------ |
43
|
|
|
*/ |
44
|
|
|
/** |
45
|
|
|
* Make exception. |
46
|
|
|
* |
47
|
|
|
* @param int $errorCode |
48
|
|
|
* @param string $errorMessage |
49
|
|
|
* |
50
|
|
|
* @return mixed |
51
|
|
|
*/ |
52
|
12 |
|
public static function make($errorCode, $errorMessage) |
53
|
|
|
{ |
54
|
12 |
|
$exception = Arr::get(self::$supported, $errorCode, Errors\Error::class); |
55
|
|
|
|
56
|
12 |
|
return new $exception($errorMessage, $errorCode); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|