ExceptionFactory::make()   A
last analyzed

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
    /**
19
     * Supported exceptions.
20
     *
21
     * @var array
22
     */
23
    protected static $supported = [
24
        E_ERROR             => Errors\Error::class,
25
        E_WARNING           => Errors\Warning::class,
26
        E_PARSE             => Errors\Parse::class,
27
        E_NOTICE            => Errors\Notice::class,
28
        E_CORE_ERROR        => Errors\CoreError::class,
29
        E_CORE_WARNING      => Errors\CoreWarning::class,
30
        E_COMPILE_ERROR     => Errors\CompileError::class,
31
        E_COMPILE_WARNING   => Errors\CompileWarning::class,
32
        E_USER_ERROR        => Errors\UserError::class,
33
        E_USER_WARNING      => Errors\UserWarning::class,
34
        E_USER_NOTICE       => Errors\UserNotice::class,
35
        E_STRICT            => Errors\Strict::class,
36
        E_RECOVERABLE_ERROR => Errors\RecoverableError::class,
37
        E_DEPRECATED        => Errors\Deprecated::class,
38
        E_USER_DEPRECATED   => Errors\UserDeprecated::class,
39
    ];
40
41
    /* -----------------------------------------------------------------
42
     |  Main Methods
43
     | -----------------------------------------------------------------
44
     */
45
46
    /**
47
     * Make exception.
48
     *
49
     * @param  int     $errorCode
50
     * @param  string  $errorMessage
51
     *
52
     * @return mixed
53
     */
54 6
    public static function make($errorCode, $errorMessage)
55
    {
56 6
        $exception = Arr::get(self::$supported, $errorCode, Errors\Error::class);
57
58 6
        return new $exception($errorMessage, $errorCode);
59
    }
60
}
61