ExceptionFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 50
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 6 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