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
|
|
|
* Name can not be set before route definition messgae |
50
|
|
|
*/ |
51
|
|
|
const NAME_BEFORE_ROUTE_DEFINITION = 'Names can not be set before route definition'; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Nam can not be set on groups message |
55
|
|
|
*/ |
56
|
|
|
const NAME_ON_GROUP = 'Name can not be set on groups message'; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Route names should be unique message |
60
|
|
|
*/ |
61
|
|
|
const NAME_IS_NOT_UNIQUE = 'Route names should be unique'; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return \Quantum\Exceptions\RouteException |
65
|
|
|
*/ |
66
|
|
|
public static function notFound(): RouteException |
67
|
|
|
{ |
68
|
|
|
return new static(self::ROUTE_NOT_FOUND, E_ERROR); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return \Quantum\Exceptions\RouteException |
73
|
|
|
*/ |
74
|
|
|
public static function notClosure(): RouteException |
75
|
|
|
{ |
76
|
|
|
return new static(self::ROUTES_NOT_CLOSURE, E_WARNING); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param string $name |
81
|
|
|
* @return \Quantum\Exceptions\RouteException |
82
|
|
|
*/ |
83
|
|
|
public static function repetitiveRouteSameMethod(string $name): RouteException |
84
|
|
|
{ |
85
|
|
|
return new static(_message(self::REPETITIVE_ROUTE_SAME_METHOD, $name), E_WARNING); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return \Quantum\Exceptions\RouteException |
90
|
|
|
*/ |
91
|
|
|
public static function repetitiveRouteDifferentModules(): RouteException |
92
|
|
|
{ |
93
|
|
|
return new static(self::REPETITIVE_ROUTE_DIFFERENT_MODULES, E_WARNING); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param string|null $name |
98
|
|
|
* @return \Quantum\Exceptions\RouteException |
99
|
|
|
*/ |
100
|
|
|
public static function incorrectMethod(?string $name): RouteException |
101
|
|
|
{ |
102
|
|
|
return new static(_message(self::INCORRECT_METHOD, $name), E_WARNING); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return \Quantum\Exceptions\RouteException |
107
|
|
|
*/ |
108
|
|
|
public static function nameBeforeDefinition(): RouteException |
109
|
|
|
{ |
110
|
|
|
return new static(self::NAME_BEFORE_ROUTE_DEFINITION); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return \Quantum\Exceptions\RouteException |
115
|
|
|
*/ |
116
|
|
|
public static function nameOnGroup(): RouteException |
117
|
|
|
{ |
118
|
|
|
return new static(self::NAME_ON_GROUP); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return \Quantum\Exceptions\RouteException |
123
|
|
|
*/ |
124
|
|
|
public static function nonUniqueName(): RouteException |
125
|
|
|
{ |
126
|
|
|
return new static(self::NAME_IS_NOT_UNIQUE); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|