Completed
Push — master ( d55578...b36807 )
by Arman
16s queued 12s
created

RouteException   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A notFound() 0 3 1
A repetitiveRouteSameMethod() 0 3 1
A repetitiveRouteDifferentModules() 0 3 1
A incorrectMethod() 0 3 1
A notClosure() 0 3 1
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.5.0
13
 */
14
15
namespace Quantum\Exceptions;
16
17
/**
18
 * Class RouteException
19
 * @package Quantum\Exceptions
20
 */
21
class RouteException extends \Exception
22
{
23
    /**
24
     * Route not found message
25
     */
26
    const ROUTE_NOT_FOUND = 'Route Not Found';
27
28
    /**
29
     * Route is not a closure message
30
     */
31
    const ROUTES_NOT_CLOSURE = 'Route is not a closure';
32
33
    /**
34
     * Repetitive route message with same method
35
     */
36
    const REPETITIVE_ROUTE_SAME_METHOD = 'Repetitive Routes with same method `{%1}`';
37
38
    /**
39
     * Repetitive route message with in different modules message
40
     */
41
    const REPETITIVE_ROUTE_DIFFERENT_MODULES = 'Repetitive Routes in different modules';
42
43
    /**
44
     * Incorrect method message
45
     */
46
    const INCORRECT_METHOD = 'Incorrect Method `{%1}`';
47
48
    /**
49
     * @return \Quantum\Exceptions\RouteException
50
     */
51
    public static function notFound(): RouteException
52
    {
53
        return new static(self::ROUTE_NOT_FOUND, E_ERROR);
54
    }
55
56
    /**
57
     * @return \Quantum\Exceptions\RouteException
58
     */
59
    public static function notClosure(): RouteException
60
    {
61
        return new static(self::ROUTES_NOT_CLOSURE, E_WARNING);
62
    }
63
64
    /**
65
     * @param string $name
66
     * @return \Quantum\Exceptions\RouteException
67
     */
68
    public static function repetitiveRouteSameMethod(string $name): RouteException
69
    {
70
        return new static(_message(self::REPETITIVE_ROUTE_SAME_METHOD, $name), E_WARNING);
71
    }
72
73
    /**
74
     * @return \Quantum\Exceptions\RouteException
75
     */
76
    public static function repetitiveRouteDifferentModules(): RouteException
77
    {
78
        return new static(self::REPETITIVE_ROUTE_DIFFERENT_MODULES, E_WARNING);
79
    }
80
81
    /**
82
     * @param string|null $name
83
     * @return \Quantum\Exceptions\RouteException
84
     */
85
    public static function incorrectMethod(?string $name): RouteException
86
    {
87
        return new static(_message(self::INCORRECT_METHOD, $name), E_WARNING);
88
    }
89
}
90