Completed
Push — master ( 1829f7...f36413 )
by ARCANEDEV
08:45
created

ExceptionFactory::make()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
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