Completed
Push — master ( 8e8e44...d679b5 )
by Restu
13:25
created

Route::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 9
c 1
b 0
f 1
nc 1
nop 7
dl 0
loc 11
rs 9.4285
1
<?php
2
namespace JayaCode\Framework\Core\Route;
3
4
/**
5
 * Class Route
6
 * @package JayaCode\Framework\Core\Route
7
 */
8
class Route
9
{
10
    /**
11
     * @var string
12
     */
13
    public $path;
14
15
    /**
16
     * @var string
17
     */
18
    public $action;
19
20
    /**
21
     * @var string
22
     */
23
    public $id;
24
25
    /**
26
     * @var string
27
     */
28
    public $controller;
29
30
    /**
31
     * @var string
32
     */
33
    public $method;
34
35
    /**
36
     * @var string
37
     */
38
    public $middleware;
39
40
    /**
41
     * @var string
42
     */
43
    public $validation;
44
45
    /**
46
     * @param $id
47
     * @param $path
48
     * @param $action
49
     * @param string $controller
50
     * @param string $method
51
     * @param string $middleware
52
     * @param string $validation
53
     */
54
    public function __construct(
55
        $id,
56
        $path,
57
        $action,
58
        $controller = null,
59
        $method = "GET",
60
        $middleware = null,
61
        $validation = null
62
    ) {
63
64
        $this->path = $path;
65
        $this->action = $action;
66
        $this->id = $id;
67
        $this->controller = $controller;
68
        $this->method = $method;
69
        $this->middleware = $middleware;
70
        $this->validation = $validation;
71
    }
72
73
    /**
74
     * @param $id
75
     * @param $path
76
     * @param $action
77
     * @param string $controller
78
     * @param string $method
79
     * @param string $middleware
80
     * @param string $validation
81
     * @return static
82
     */
83
    public static function create(
84
        $id,
85
        $path,
86
        $action,
87
        $controller = null,
88
        $method = "GET",
89
        $middleware = null,
90
        $validation = null
91
    ) {
92
        return new static($id, $path, $action, $controller, $method, $middleware, $validation);
93
    }
94
95
96
    /**
97
     * @param $id
98
     * @param $path
99
     * @param $action
100
     * @param string $controller
101
     * @param string $method
102
     * @param string $middleware
103
     * @param string $validation
104
     * @return static
105
     */
106
    public static function get(
107
        $id,
108
        $path,
109
        $action,
110
        $controller = null,
111
        $method = "GET",
112
        $middleware = null,
113
        $validation = null
114
    ) {
115
        return new static($id, $path, $action, $controller, $method, $middleware, $validation);
116
    }
117
118
    /**
119
     * @param $id
120
     * @param $path
121
     * @param $action
122
     * @param string $controller
123
     * @param string $method
124
     * @param string $middleware
125
     * @param string $validation
126
     * @return static
127
     */
128
    public static function post(
129
        $id,
130
        $path,
131
        $action,
132
        $controller = null,
133
        $method = "POST",
134
        $middleware = null,
135
        $validation = null
136
    ) {
137
        return new static($id, $path, $action, $controller, $method, $middleware, $validation);
138
    }
139
140
    /**
141
     * @param $id
142
     * @param $path
143
     * @param $action
144
     * @param string $controller
145
     * @param string $method
146
     * @param string $middleware
147
     * @param string $validation
148
     * @return static
149
     */
150
    public static function put(
151
        $id,
152
        $path,
153
        $action,
154
        $controller = null,
155
        $method = "PUT",
156
        $middleware = null,
157
        $validation = null
158
    ) {
159
        return new static($id, $path, $action, $controller, $method, $middleware, $validation);
160
    }
161
162
    public static function head(
163
        $id,
164
        $path,
165
        $action,
166
        $controller = null,
167
        $method = "HEAD",
168
        $middleware = null,
169
        $validation = null
170
    ) {
171
        return new static($id, $path, $action, $controller, $method, $middleware, $validation);
172
    }
173
174
    /**
175
     * @param $id
176
     * @param $path
177
     * @param $action
178
     * @param string $controller
179
     * @param string $method
180
     * @param string $middleware
181
     * @param string $validation
182
     * @return static
183
     */
184
    public static function delete(
185
        $id,
186
        $path,
187
        $action,
188
        $controller = null,
189
        $method = "DELETE",
190
        $middleware = null,
191
        $validation = null
192
    ) {
193
        return new static($id, $path, $action, $controller, $method, $middleware, $validation);
194
    }
195
196
    /**
197
     * @param $id
198
     * @param $path
199
     * @param $action
200
     * @param string $controller
201
     * @param string $method
202
     * @param string $middleware
203
     * @param string $validation
204
     * @return static
205
     */
206
    public static function options(
207
        $id,
208
        $path,
209
        $action,
210
        $controller = null,
211
        $method = "OPTIONS",
212
        $middleware = null,
213
        $validation = null
214
    ) {
215
        return new static($id, $path, $action, $controller, $method, $middleware, $validation);
216
    }
217
218
    /**
219
     * @param $id
220
     * @param $path
221
     * @param $action
222
     * @param string $controller
223
     * @param string $method
224
     * @param string $middleware
225
     * @param string $validation
226
     * @return static
227
     */
228
    public static function connect(
229
        $id,
230
        $path,
231
        $action,
232
        $controller = null,
233
        $method = "CONNECT",
234
        $middleware = null,
235
        $validation = null
236
    ) {
237
        return new static($id, $path, $action, $controller, $method, $middleware, $validation);
238
    }
239
}
240