1 | <?php |
||
8 | class Order { |
||
9 | |||
10 | /** |
||
11 | * @var string Name of the route |
||
12 | */ |
||
13 | private $name; |
||
14 | |||
15 | /** |
||
16 | * @var string The path pattern. |
||
17 | */ |
||
18 | private $uri; |
||
19 | |||
20 | /** |
||
21 | * @var callable The callback response. |
||
22 | */ |
||
23 | private $response; |
||
24 | |||
25 | /** |
||
26 | * @var string The request method for the path pattern. |
||
27 | */ |
||
28 | private $method; |
||
29 | |||
30 | /** |
||
31 | * @var array Contains all middlewares associate to the action. |
||
32 | */ |
||
33 | private $middlewares = []; |
||
34 | |||
35 | /** |
||
36 | * @var array The types that are supported(for middlewares). |
||
37 | */ |
||
38 | private $middlewareTypes = ['before', 'after']; |
||
39 | |||
40 | /** |
||
41 | * @var array request methods availables. |
||
42 | */ |
||
43 | private $availableRequestMethods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH']; |
||
44 | |||
45 | public function __construct($uri, $method, $response, array $middlewares = [], $name = null) { |
||
57 | |||
58 | /** |
||
59 | * Returns the route name. |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | |||
64 | public function getName() { |
||
67 | |||
68 | /** |
||
69 | * Returns the uri(the pattern path). |
||
70 | * |
||
71 | * @return mixed |
||
72 | */ |
||
73 | |||
74 | public function getUri() { |
||
77 | |||
78 | /** |
||
79 | * Returns the request method registered. |
||
80 | * |
||
81 | * @return mixed |
||
82 | */ |
||
83 | |||
84 | public function getMethod() { |
||
87 | |||
88 | /** |
||
89 | * Returns the callback associated to the pattern. |
||
90 | * |
||
91 | * @return mixed |
||
92 | */ |
||
93 | |||
94 | public function getResponse() { |
||
97 | |||
98 | /** |
||
99 | * Returns a list of middlewares registered. |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | |||
104 | public function getMiddlewares() { |
||
107 | |||
108 | /** |
||
109 | * Checks if the middleware contains before callback. |
||
110 | * |
||
111 | * @return bool |
||
112 | */ |
||
113 | |||
114 | public function hasBefore() { |
||
117 | |||
118 | /** |
||
119 | * Checks if the middleware contains after callback. |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | |||
124 | public function hasAfter() { |
||
127 | |||
128 | /** |
||
129 | * Checks if middlewares passed as an associative array |
||
130 | * don't contain keys different to "before" and "after". |
||
131 | * |
||
132 | * @param array $middleware The associative array containing |
||
133 | * middleware callbacks. |
||
134 | * @return bool |
||
135 | * @throws InvalidMiddlewareException |
||
136 | */ |
||
137 | |||
138 | private function isValidMiddleware($middleware) { |
||
155 | } |