@@ -12,32 +12,32 @@ discard block |
||
12 | 12 | use Psr\Http\Message\ServerRequestInterface; |
13 | 13 | use Psr\Http\Message\UriInterface; |
14 | 14 | |
15 | -describe("Router", function () { |
|
15 | +describe("Router", function() { |
|
16 | 16 | |
17 | 17 | |
18 | - beforeEach(function () { |
|
18 | + beforeEach(function() { |
|
19 | 19 | |
20 | 20 | |
21 | 21 | $this->router = new Router(); |
22 | - $this->export = function ($request) { |
|
22 | + $this->export = function($request) { |
|
23 | 23 | |
24 | 24 | return array_intersect_key($request, array_fill_keys(['path', 'method', 'host', 'scheme'], true)); |
25 | 25 | }; |
26 | 26 | }); |
27 | - describe("->__construct()", function () { |
|
27 | + describe("->__construct()", function() { |
|
28 | 28 | |
29 | 29 | |
30 | - it("formats the basePath", function () { |
|
30 | + it("formats the basePath", function() { |
|
31 | 31 | |
32 | 32 | |
33 | 33 | $router = new Router(['basePath' => '/']); |
34 | 34 | expect($router->basePath())->toBe(''); |
35 | 35 | }); |
36 | 36 | }); |
37 | - describe("->basePath()", function () { |
|
37 | + describe("->basePath()", function() { |
|
38 | 38 | |
39 | 39 | |
40 | - it("sets an empty basePath", function () { |
|
40 | + it("sets an empty basePath", function() { |
|
41 | 41 | |
42 | 42 | |
43 | 43 | expect($this->router->setBasePath('/'))->toBe($this->router); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | expect($this->router->setBasePath(''))->toBe($this->router); |
46 | 46 | expect($this->router->basePath())->toBe(''); |
47 | 47 | }); |
48 | - it("adds an leading slash for non empty basePath", function () { |
|
48 | + it("adds an leading slash for non empty basePath", function() { |
|
49 | 49 | |
50 | 50 | |
51 | 51 | expect($this->router->setBasePath('app'))->toBe($this->router); |
@@ -54,24 +54,24 @@ discard block |
||
54 | 54 | expect($this->router->basePath())->toBe('/base'); |
55 | 55 | }); |
56 | 56 | }); |
57 | - describe("->bind()", function () { |
|
57 | + describe("->bind()", function() { |
|
58 | 58 | |
59 | 59 | |
60 | - it("binds a named route", function () { |
|
60 | + it("binds a named route", function() { |
|
61 | 61 | |
62 | 62 | |
63 | 63 | $r = $this->router; |
64 | - $route = $r->bind('foo/bar', ['name' => 'foo'], function () { |
|
64 | + $route = $r->bind('foo/bar', ['name' => 'foo'], function() { |
|
65 | 65 | return 'hello'; |
66 | 66 | }); |
67 | 67 | expect(isset($r['foo']))->toBe(true); |
68 | 68 | expect($r['foo'])->toBe($route); |
69 | 69 | }); |
70 | - it("matches on methods", function () { |
|
70 | + it("matches on methods", function() { |
|
71 | 71 | |
72 | 72 | |
73 | 73 | $r = $this->router; |
74 | - $r->bind('foo/bar', ['methods' => ['POST', 'PUT']], function () { |
|
74 | + $r->bind('foo/bar', ['methods' => ['POST', 'PUT']], function() { |
|
75 | 75 | }); |
76 | 76 | $route = $r->route('foo/bar', 'POST'); |
77 | 77 | expect($route->Methods())->toBe(['POST', 'PUT']); |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | expect($e->getMessage())->toBe("No route found for `*:*:GET:/bar/foo`."); |
84 | 84 | } |
85 | 85 | }); |
86 | - it("supports lowercase method names", function () { |
|
86 | + it("supports lowercase method names", function() { |
|
87 | 87 | |
88 | 88 | |
89 | 89 | $r = $this->router; |
90 | - $r->bind('foo/bar', ['methods' => ['POST', 'PUT']], function () { |
|
90 | + $r->bind('foo/bar', ['methods' => ['POST', 'PUT']], function() { |
|
91 | 91 | }); |
92 | 92 | $route = $r->route('foo/bar', 'post'); |
93 | 93 | expect($route->Methods())->toBe(['POST', 'PUT']); |
@@ -99,42 +99,42 @@ discard block |
||
99 | 99 | expect($e->getMessage())->toBe("No route found for `*:*:GET:/bar/foo`."); |
100 | 100 | } |
101 | 101 | }); |
102 | - it("matches on same path different methods", function () { |
|
102 | + it("matches on same path different methods", function() { |
|
103 | 103 | |
104 | 104 | $r = $this->router; |
105 | - $r->bind('foo/bar', ['name' => 'foo', 'methods' => ['POST']], function () { |
|
105 | + $r->bind('foo/bar', ['name' => 'foo', 'methods' => ['POST']], function() { |
|
106 | 106 | }); |
107 | - $r->bind('foo/bar', ['name' => 'bar', 'methods' => ['PUT']], function () { |
|
107 | + $r->bind('foo/bar', ['name' => 'bar', 'methods' => ['PUT']], function() { |
|
108 | 108 | }); |
109 | 109 | $route = $r->route('foo/bar', 'POST'); |
110 | 110 | expect($route->name)->toBe('foo'); |
111 | 111 | $route = $r->route('foo/bar', 'PUT'); |
112 | 112 | expect($route->name)->toBe('bar'); |
113 | 113 | }); |
114 | - it("throws an exception when trying to use the `'method'` option", function () { |
|
114 | + it("throws an exception when trying to use the `'method'` option", function() { |
|
115 | 115 | |
116 | 116 | |
117 | - $closure = function () { |
|
117 | + $closure = function() { |
|
118 | 118 | |
119 | 119 | $r = $this->router; |
120 | - $r->bind('foo', ['method' => 'GET'], function () { |
|
120 | + $r->bind('foo', ['method' => 'GET'], function() { |
|
121 | 121 | }); |
122 | 122 | }; |
123 | 123 | expect($closure)->toThrow(new RouterException("Use the `'methods'` option to limit HTTP verbs on a route binding definition.")); |
124 | 124 | }); |
125 | 125 | }); |
126 | - describe("->link()", function () { |
|
126 | + describe("->link()", function() { |
|
127 | 127 | |
128 | 128 | |
129 | - it("forwards router base path", function () { |
|
129 | + it("forwards router base path", function() { |
|
130 | 130 | |
131 | 131 | |
132 | 132 | $r = $this->router; |
133 | 133 | $r->basePath('app'); |
134 | 134 | |
135 | - $r->group(['host' => 'www.{domain}.com', 'scheme' => 'https'], function ($r) { |
|
135 | + $r->group(['host' => 'www.{domain}.com', 'scheme' => 'https'], function($r) { |
|
136 | 136 | |
137 | - $r->bind('foo/{bar}', ['name' => 'foo'], function () { |
|
137 | + $r->bind('foo/{bar}', ['name' => 'foo'], function() { |
|
138 | 138 | }); |
139 | 139 | }); |
140 | 140 | $link = $r->link('foo', [ |
@@ -143,28 +143,28 @@ discard block |
||
143 | 143 | ], ['absolute' => true]); |
144 | 144 | expect($link)->toBe('https://www.example.com/app/foo/baz'); |
145 | 145 | }); |
146 | - it("maintains prefixes in nested routes", function () { |
|
146 | + it("maintains prefixes in nested routes", function() { |
|
147 | 147 | |
148 | 148 | |
149 | 149 | $r = $this->router; |
150 | - $r->group('foo', ['name' => 'foz'], function ($r) { |
|
150 | + $r->group('foo', ['name' => 'foz'], function($r) { |
|
151 | 151 | |
152 | - $r->group('bar', ['name' => 'baz'], function ($r) { |
|
152 | + $r->group('bar', ['name' => 'baz'], function($r) { |
|
153 | 153 | |
154 | - $r->bind('{var1}', ['name' => 'quz'], function () { |
|
154 | + $r->bind('{var1}', ['name' => 'quz'], function() { |
|
155 | 155 | }); |
156 | 156 | }); |
157 | 157 | }); |
158 | 158 | $link = $r->link('foz.baz.quz', ['var1' => 'hello']); |
159 | 159 | expect($link)->toBe('/foo/bar/hello'); |
160 | 160 | }); |
161 | - it("persists persisted parameters in a dispatching context", function () { |
|
161 | + it("persists persisted parameters in a dispatching context", function() { |
|
162 | 162 | |
163 | 163 | |
164 | 164 | $r = $this->router; |
165 | - $r->group('{locale:en|fr}', ['persist' => 'locale'], function ($r) { |
|
165 | + $r->group('{locale:en|fr}', ['persist' => 'locale'], function($r) { |
|
166 | 166 | |
167 | - $r->bind('{controller}/{action}[/{id}]', ['name' => 'controller'], function () { |
|
167 | + $r->bind('{controller}/{action}[/{id}]', ['name' => 'controller'], function() { |
|
168 | 168 | }); |
169 | 169 | }); |
170 | 170 | $r->route('fr/post/index'); |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | ]); |
183 | 183 | expect($link)->toBe('/en/post/view/5'); |
184 | 184 | }); |
185 | - it("overrides persisted parameters in a dispatching context", function () { |
|
185 | + it("overrides persisted parameters in a dispatching context", function() { |
|
186 | 186 | |
187 | 187 | |
188 | 188 | $r = $this->router; |
189 | - $r->group('{locale:en|fr}', ['persist' => 'locale'], function ($r) { |
|
189 | + $r->group('{locale:en|fr}', ['persist' => 'locale'], function($r) { |
|
190 | 190 | |
191 | - $r->bind('{controller}/{action}[/{id}]', ['name' => 'controller'], function () { |
|
191 | + $r->bind('{controller}/{action}[/{id}]', ['name' => 'controller'], function() { |
|
192 | 192 | }); |
193 | 193 | }); |
194 | 194 | $r->route('fr/post/index'); |
@@ -200,24 +200,24 @@ discard block |
||
200 | 200 | ]); |
201 | 201 | expect($link)->toBe('/en/post/view/5'); |
202 | 202 | }); |
203 | - it("throws an exception when no route is found for a specified name", function () { |
|
203 | + it("throws an exception when no route is found for a specified name", function() { |
|
204 | 204 | |
205 | 205 | |
206 | - $closure = function () { |
|
206 | + $closure = function() { |
|
207 | 207 | |
208 | 208 | $this->router->link('not.binded.yet', []); |
209 | 209 | }; |
210 | 210 | expect($closure)->toThrow(new RouterException("No route defined for `'not.binded.yet'`, bind it first with `bind()`.")); |
211 | 211 | }); |
212 | 212 | }); |
213 | - describe("->route()", function () { |
|
213 | + describe("->route()", function() { |
|
214 | 214 | |
215 | 215 | |
216 | - it("routes on a simple route", function () { |
|
216 | + it("routes on a simple route", function() { |
|
217 | 217 | |
218 | 218 | |
219 | 219 | $r = $this->router; |
220 | - $r->bind('foo/bar', function () { |
|
220 | + $r->bind('foo/bar', function() { |
|
221 | 221 | }); |
222 | 222 | $route = $r->route('foo/bar', 'GET'); |
223 | 223 | expect($this->export($route->request))->toEqual([ |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | expect($e->getMessage())->toBe("No route found for `*:*:GET:/bar/foo`."); |
233 | 233 | } |
234 | 234 | }); |
235 | - it("routes on a named route", function () { |
|
235 | + it("routes on a named route", function() { |
|
236 | 236 | |
237 | 237 | |
238 | 238 | $r = $this->router; |
239 | - $r->bind('foo/bar', ['name' => 'foo'], function () { |
|
239 | + $r->bind('foo/bar', ['name' => 'foo'], function() { |
|
240 | 240 | }); |
241 | 241 | $route = $r->route('foo/bar', 'GET'); |
242 | 242 | expect($route->name)->toBe('foo'); |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | expect($e->getMessage())->toBe("No route found for `*:*:GET:/bar/foo`."); |
247 | 247 | } |
248 | 248 | }); |
249 | - it("supports empty as index route", function () { |
|
249 | + it("supports empty as index route", function() { |
|
250 | 250 | |
251 | 251 | |
252 | 252 | $r = $this->router; |
253 | - $r->bind('', function () { |
|
253 | + $r->bind('', function() { |
|
254 | 254 | }); |
255 | 255 | $route = $r->route('', 'GET'); |
256 | 256 | expect($this->export($route->request))->toEqual([ |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | 'path' => '' |
261 | 261 | ]); |
262 | 262 | }); |
263 | - it("supports a slash as indes route", function () { |
|
263 | + it("supports a slash as indes route", function() { |
|
264 | 264 | |
265 | 265 | |
266 | 266 | $r = $this->router; |
267 | - $r->bind('/', function () { |
|
267 | + $r->bind('/', function() { |
|
268 | 268 | }); |
269 | 269 | $route = $r->route('', 'GET'); |
270 | 270 | expect($this->export($route->request))->toEqual([ |
@@ -274,11 +274,11 @@ discard block |
||
274 | 274 | 'path' => '' |
275 | 275 | ]); |
276 | 276 | }); |
277 | - it("supports route variables", function () { |
|
277 | + it("supports route variables", function() { |
|
278 | 278 | |
279 | 279 | |
280 | 280 | $r = $this->router; |
281 | - $r->get('foo/{param}', function () { |
|
281 | + $r->get('foo/{param}', function() { |
|
282 | 282 | }); |
283 | 283 | $route = $r->route('foo/bar', 'GET'); |
284 | 284 | expect($route->params)->toBe(['param' => 'bar']); |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | expect($e->getMessage())->toBe("No route found for `*:*:GET:/bar/foo`."); |
289 | 289 | } |
290 | 290 | }); |
291 | - it("supports constrained route variables", function () { |
|
291 | + it("supports constrained route variables", function() { |
|
292 | 292 | |
293 | 293 | |
294 | 294 | $r = $this->router; |
295 | - $r->get('foo/{var1:\d+}', function () { |
|
295 | + $r->get('foo/{var1:\d+}', function() { |
|
296 | 296 | }); |
297 | 297 | $route = $r->route('foo/25', 'GET'); |
298 | 298 | expect($route->params)->toBe(['var1' => '25']); |
@@ -302,22 +302,22 @@ discard block |
||
302 | 302 | expect($e->getMessage())->toBe("No route found for `*:*:GET:/foo/bar`."); |
303 | 303 | } |
304 | 304 | }); |
305 | - it("supports optional segments with variables", function () { |
|
305 | + it("supports optional segments with variables", function() { |
|
306 | 306 | |
307 | 307 | |
308 | 308 | $r = $this->router; |
309 | - $r->get('foo[/{var1}]', function () { |
|
309 | + $r->get('foo[/{var1}]', function() { |
|
310 | 310 | }); |
311 | 311 | $route = $r->route('foo', 'GET'); |
312 | 312 | expect($route->params)->toBe(['var1' => null]); |
313 | 313 | $route = $r->route('foo/bar', 'GET'); |
314 | 314 | expect($route->params)->toBe(['var1' => 'bar']); |
315 | 315 | }); |
316 | - it("supports repeatable segments", function () { |
|
316 | + it("supports repeatable segments", function() { |
|
317 | 317 | |
318 | 318 | |
319 | 319 | $r = $this->router; |
320 | - $r->get('foo[/:{var1}]*[/bar[/:{var2}]*]', function () { |
|
320 | + $r->get('foo[/:{var1}]*[/bar[/:{var2}]*]', function() { |
|
321 | 321 | }); |
322 | 322 | $route = $r->route('foo', 'GET'); |
323 | 323 | expect($route->params)->toBe([ |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | 'var2' => ['fuz'] |
336 | 336 | ]); |
337 | 337 | }); |
338 | - it("supports optional segments with custom variable regex", function () { |
|
338 | + it("supports optional segments with custom variable regex", function() { |
|
339 | 339 | |
340 | 340 | |
341 | 341 | $r = $this->router; |
342 | - $r->get('foo[/{var1:\d+}]', function () { |
|
342 | + $r->get('foo[/{var1:\d+}]', function() { |
|
343 | 343 | }); |
344 | 344 | $route = $r->route('foo', 'GET'); |
345 | 345 | expect($route->params)->toBe(['var1' => null]); |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | expect($e->getMessage())->toBe("No route found for `*:*:GET:/foo/baz`."); |
352 | 352 | } |
353 | 353 | }); |
354 | - it("supports multiple optional segments", function () { |
|
354 | + it("supports multiple optional segments", function() { |
|
355 | 355 | |
356 | 356 | |
357 | 357 | $patterns = [ |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $r = $this->router; |
361 | 361 | |
362 | 362 | foreach ($patterns as $pattern) { |
363 | - $r->get($pattern, function () { |
|
363 | + $r->get($pattern, function() { |
|
364 | 364 | }); |
365 | 365 | $route = $r->route('foo', 'GET'); |
366 | 366 | expect($route->params)->toBe(['var1' => 'foo', 'var2' => null]); |
@@ -369,13 +369,13 @@ discard block |
||
369 | 369 | $r->clear(); |
370 | 370 | }; |
371 | 371 | }); |
372 | - it("supports host variables", function () { |
|
372 | + it("supports host variables", function() { |
|
373 | 373 | |
374 | 374 | |
375 | 375 | $r = $this->router; |
376 | - $r->get('foo/{var1:\d+}', ['host' => 'foo.{domain}.bar'], function () { |
|
376 | + $r->get('foo/{var1:\d+}', ['host' => 'foo.{domain}.bar'], function() { |
|
377 | 377 | }); |
378 | - $r->get('foo/{var1:\d+}', ['host' => 'foo.{domain}.baz'], function () { |
|
378 | + $r->get('foo/{var1:\d+}', ['host' => 'foo.{domain}.baz'], function() { |
|
379 | 379 | }); |
380 | 380 | $route = $r->route('foo/25', 'GET', 'foo.biz.bar'); |
381 | 381 | expect($route->Host()->pattern())->toBe('foo.{domain}.bar'); |
@@ -384,27 +384,27 @@ discard block |
||
384 | 384 | expect($route->Host()->pattern())->toBe('foo.{domain}.baz'); |
385 | 385 | expect($route->params)->toBe(['domain' => 'buz', 'var1' => '50']); |
386 | 386 | }); |
387 | - it("supports constrained host variables", function () { |
|
387 | + it("supports constrained host variables", function() { |
|
388 | 388 | |
389 | 389 | |
390 | 390 | $r = $this->router; |
391 | - $r->get('foo/{var1:\d+}', ['host' => '{subdomain:foo}.{domain}.bar'], function () { |
|
391 | + $r->get('foo/{var1:\d+}', ['host' => '{subdomain:foo}.{domain}.bar'], function() { |
|
392 | 392 | }); |
393 | 393 | $route = $r->route('foo/25', 'GET', 'foo.biz.bar'); |
394 | - expect($route->params)->toBe([ 'subdomain' => 'foo', 'domain' => 'biz', 'var1' => '25']); |
|
394 | + expect($route->params)->toBe(['subdomain' => 'foo', 'domain' => 'biz', 'var1' => '25']); |
|
395 | 395 | try { |
396 | 396 | $route = $r->route('foo/bar', 'GET', 'foo.biz.bar'); |
397 | 397 | } catch (RouteNotFoundException $e) { |
398 | 398 | expect($e->getMessage())->toBe("No route found for `*:foo.biz.bar:GET:/foo/bar`."); |
399 | 399 | } |
400 | 400 | }); |
401 | - it("supports absolute URL", function () { |
|
401 | + it("supports absolute URL", function() { |
|
402 | 402 | |
403 | 403 | |
404 | 404 | $r = $this->router; |
405 | - $r->get('foo/{var1:\d+}', ['host' => 'foo.{domain}.bar'], function () { |
|
405 | + $r->get('foo/{var1:\d+}', ['host' => 'foo.{domain}.bar'], function() { |
|
406 | 406 | }); |
407 | - $r->get('foo/{var1:\d+}', ['host' => 'foo.{domain}.baz'], function () { |
|
407 | + $r->get('foo/{var1:\d+}', ['host' => 'foo.{domain}.baz'], function() { |
|
408 | 408 | }); |
409 | 409 | $route = $r->route('http://foo.biz.bar/foo/25', 'GET'); |
410 | 410 | expect($route->Host()->pattern())->toBe('foo.{domain}.bar'); |
@@ -413,23 +413,23 @@ discard block |
||
413 | 413 | expect($route->Host()->pattern())->toBe('foo.{domain}.baz'); |
414 | 414 | expect($route->params)->toBe(['domain' => 'buz', 'var1' => '50']); |
415 | 415 | }); |
416 | - it("supports RESTful routes", function () { |
|
416 | + it("supports RESTful routes", function() { |
|
417 | 417 | |
418 | 418 | |
419 | 419 | $r = $this->router; |
420 | - $r->get('foo/bar', function () { |
|
420 | + $r->get('foo/bar', function() { |
|
421 | 421 | }); |
422 | - $r->head('foo/bar', function () { |
|
422 | + $r->head('foo/bar', function() { |
|
423 | 423 | }); |
424 | - $r->post('foo/bar', function () { |
|
424 | + $r->post('foo/bar', function() { |
|
425 | 425 | }); |
426 | - $r->put('foo/bar', function () { |
|
426 | + $r->put('foo/bar', function() { |
|
427 | 427 | }); |
428 | - $r->patch('foo/bar', function () { |
|
428 | + $r->patch('foo/bar', function() { |
|
429 | 429 | }); |
430 | - $r->delete('foo/bar', function () { |
|
430 | + $r->delete('foo/bar', function() { |
|
431 | 431 | }); |
432 | - $r->options('foo/bar', function () { |
|
432 | + $r->options('foo/bar', function() { |
|
433 | 433 | }); |
434 | 434 | $methods = ['OPTIONS', 'DELETE', 'PATCH', 'PUT', 'POST', 'HEAD', 'GET']; |
435 | 435 | $route = $r->route('foo/bar', 'GET'); |
@@ -447,11 +447,11 @@ discard block |
||
447 | 447 | $route = $r->route('foo/bar', 'OPTIONS'); |
448 | 448 | expect($route->Methods())->toBe($methods); |
449 | 449 | }); |
450 | - it("matches relationships based routes", function () { |
|
450 | + it("matches relationships based routes", function() { |
|
451 | 451 | |
452 | 452 | |
453 | 453 | $r = $this->router; |
454 | - $r->get('[/{relations:[^/]+/[^/:][^/]*}]*/comment[/{id:[^/:][^/]*}][/:{action}]', function () { |
|
454 | + $r->get('[/{relations:[^/]+/[^/:][^/]*}]*/comment[/{id:[^/:][^/]*}][/:{action}]', function() { |
|
455 | 455 | }); |
456 | 456 | $route = $r->route('blog/1/post/22/comment/:show', 'GET'); |
457 | 457 | expect($route->params)->toBe([ |
@@ -463,35 +463,35 @@ discard block |
||
463 | 463 | 'action' => 'show' |
464 | 464 | ]); |
465 | 465 | }); |
466 | - it("dispatches HEAD requests on matching GET routes if the HEAD routes are missing", function () { |
|
466 | + it("dispatches HEAD requests on matching GET routes if the HEAD routes are missing", function() { |
|
467 | 467 | |
468 | 468 | |
469 | 469 | $r = $this->router; |
470 | - $r->get('foo/bar', function () { |
|
470 | + $r->get('foo/bar', function() { |
|
471 | 471 | return 'GET'; |
472 | 472 | }); |
473 | 473 | $route = $r->route('foo/bar', 'HEAD'); |
474 | 474 | expect($route->Methods())->toBe(['GET']); |
475 | 475 | }); |
476 | - it("dispatches HEAD requests on matching HEAD routes", function () { |
|
476 | + it("dispatches HEAD requests on matching HEAD routes", function() { |
|
477 | 477 | |
478 | 478 | |
479 | 479 | $r = $this->router; |
480 | 480 | |
481 | - $r->head('foo/bar', function () { |
|
481 | + $r->head('foo/bar', function() { |
|
482 | 482 | return 'HEAD'; |
483 | 483 | }); |
484 | - $r->get('foo/bar', function () { |
|
484 | + $r->get('foo/bar', function() { |
|
485 | 485 | return 'GET'; |
486 | 486 | }); |
487 | 487 | $route = $r->route('foo/bar', 'HEAD'); |
488 | 488 | expect($route->Methods())->toBe(['GET', 'HEAD']); |
489 | 489 | }); |
490 | - it("supports requests as a list of arguments", function () { |
|
490 | + it("supports requests as a list of arguments", function() { |
|
491 | 491 | |
492 | 492 | |
493 | 493 | $r = $this->router; |
494 | - $r->bind('foo/bar', function () { |
|
494 | + $r->bind('foo/bar', function() { |
|
495 | 495 | }); |
496 | 496 | $route = $r->route('foo/bar', 'GET'); |
497 | 497 | expect($this->export($route->request))->toEqual([ |
@@ -501,10 +501,10 @@ discard block |
||
501 | 501 | 'path' => 'foo/bar' |
502 | 502 | ]); |
503 | 503 | }); |
504 | - it("supports requests as an object", function () { |
|
504 | + it("supports requests as an object", function() { |
|
505 | 505 | |
506 | 506 | $r = $this->router; |
507 | - $r->bind('foo/bar', function () { |
|
507 | + $r->bind('foo/bar', function() { |
|
508 | 508 | }); |
509 | 509 | $request = Double::instance(['implements' => ServerRequestInterface::class]); |
510 | 510 | $uri = Double::instance(['implements' => UriInterface::class]); |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | $route = $r->route($request, 'GET'); |
518 | 518 | expect($route->request)->toBe($request); |
519 | 519 | }); |
520 | - it("supports requests as an array", function () { |
|
520 | + it("supports requests as an array", function() { |
|
521 | 521 | |
522 | 522 | |
523 | 523 | $r = $this->router; |
524 | - $r->bind('foo/bar', function () { |
|
524 | + $r->bind('foo/bar', function() { |
|
525 | 525 | }); |
526 | 526 | $route = $r->route(['path' => 'foo/bar'], 'GET'); |
527 | 527 | expect($this->export($route->request))->toEqual([ |
@@ -532,59 +532,59 @@ discard block |
||
532 | 532 | ]); |
533 | 533 | }); |
534 | 534 | }); |
535 | - describe("->group()", function () { |
|
535 | + describe("->group()", function() { |
|
536 | 536 | |
537 | 537 | |
538 | - it("supports nested named route", function () { |
|
538 | + it("supports nested named route", function() { |
|
539 | 539 | |
540 | 540 | |
541 | 541 | $r = $this->router; |
542 | - $r->group('foo', ['name' => 'foz'], function ($r) use (&$route) { |
|
542 | + $r->group('foo', ['name' => 'foz'], function($r) use (&$route) { |
|
543 | 543 | |
544 | - $r->group('bar', ['name' => 'baz'], function ($r) use (&$route) { |
|
544 | + $r->group('bar', ['name' => 'baz'], function($r) use (&$route) { |
|
545 | 545 | |
546 | - $route = $r->bind('{var1}', ['name' => 'quz'], function () { |
|
546 | + $route = $r->bind('{var1}', ['name' => 'quz'], function() { |
|
547 | 547 | }); |
548 | 548 | }); |
549 | 549 | }); |
550 | 550 | expect(isset($r['foz.baz.quz']))->toBe(true); |
551 | 551 | expect($r['foz.baz.quz'])->toBe($route); |
552 | 552 | }); |
553 | - it("returns a working scope", function () { |
|
553 | + it("returns a working scope", function() { |
|
554 | 554 | |
555 | 555 | |
556 | 556 | $r = $this->router; |
557 | - $route = $r->group('foo', ['name' => 'foz'], function () { |
|
558 | - })->group('bar', ['name' => 'baz'], function () { |
|
559 | - })->bind('{var1}', ['name' => 'quz'], function () { |
|
557 | + $route = $r->group('foo', ['name' => 'foz'], function() { |
|
558 | + })->group('bar', ['name' => 'baz'], function() { |
|
559 | + })->bind('{var1}', ['name' => 'quz'], function() { |
|
560 | 560 | }); |
561 | 561 | expect(isset($r['foz.baz.quz']))->toBe(true); |
562 | 562 | expect($r['foz.baz.quz'])->toBe($route); |
563 | 563 | }); |
564 | - context("with a prefix contraint", function () { |
|
564 | + context("with a prefix contraint", function() { |
|
565 | 565 | |
566 | 566 | |
567 | - beforeEach(function () { |
|
567 | + beforeEach(function() { |
|
568 | 568 | |
569 | 569 | |
570 | 570 | $r = $this->router; |
571 | - $r->group('foo', function ($r) { |
|
571 | + $r->group('foo', function($r) { |
|
572 | 572 | |
573 | - $r->bind('{var1}', function () { |
|
573 | + $r->bind('{var1}', function() { |
|
574 | 574 | }); |
575 | 575 | }); |
576 | 576 | }); |
577 | - it("respects url's prefix constraint", function () { |
|
577 | + it("respects url's prefix constraint", function() { |
|
578 | 578 | |
579 | 579 | |
580 | 580 | $r = $this->router; |
581 | 581 | $route = $r->route('foo/bar'); |
582 | 582 | expect($route->params)->toBe(['var1' => 'bar']); |
583 | 583 | }); |
584 | - it("throws an exception when the prefix does not match", function () { |
|
584 | + it("throws an exception when the prefix does not match", function() { |
|
585 | 585 | |
586 | 586 | |
587 | - $closure = function () { |
|
587 | + $closure = function() { |
|
588 | 588 | |
589 | 589 | $r = $this->router; |
590 | 590 | $route = $r->route('bar/foo', 'GET'); |
@@ -592,30 +592,30 @@ discard block |
||
592 | 592 | expect($closure)->toThrow(new RouteNotFoundException("No route found for `*:*:GET:/bar/foo`.")); |
593 | 593 | }); |
594 | 594 | }); |
595 | - context("with a prefix contraint and an optional parameter", function () { |
|
595 | + context("with a prefix contraint and an optional parameter", function() { |
|
596 | 596 | |
597 | 597 | |
598 | - beforeEach(function () { |
|
598 | + beforeEach(function() { |
|
599 | 599 | |
600 | 600 | |
601 | 601 | $r = $this->router; |
602 | - $r->group('foo', function ($r) { |
|
602 | + $r->group('foo', function($r) { |
|
603 | 603 | |
604 | - $r->bind('[{var1}]', function () { |
|
604 | + $r->bind('[{var1}]', function() { |
|
605 | 605 | }); |
606 | 606 | }); |
607 | 607 | }); |
608 | - it("respects url's prefix constraint", function () { |
|
608 | + it("respects url's prefix constraint", function() { |
|
609 | 609 | |
610 | 610 | |
611 | 611 | $r = $this->router; |
612 | 612 | $route = $r->route('foo'); |
613 | 613 | expect($route->params)->toBe(['var1' => null]); |
614 | 614 | }); |
615 | - it("throws an exception when the prefix does not match", function () { |
|
615 | + it("throws an exception when the prefix does not match", function() { |
|
616 | 616 | |
617 | 617 | |
618 | - $closure = function () { |
|
618 | + $closure = function() { |
|
619 | 619 | |
620 | 620 | $r = $this->router; |
621 | 621 | $route = $r->route('bar/foo', 'GET'); |
@@ -623,23 +623,23 @@ discard block |
||
623 | 623 | expect($closure)->toThrow(new RouteNotFoundException("No route found for `*:*:GET:/bar/foo`.")); |
624 | 624 | }); |
625 | 625 | }); |
626 | - context("with a host constraint", function () { |
|
626 | + context("with a host constraint", function() { |
|
627 | 627 | |
628 | 628 | |
629 | - beforeEach(function () { |
|
629 | + beforeEach(function() { |
|
630 | 630 | |
631 | 631 | |
632 | 632 | $r = $this->router; |
633 | - $r->group('foo', ['host' => 'foo.{domain}.bar'], function ($r) { |
|
633 | + $r->group('foo', ['host' => 'foo.{domain}.bar'], function($r) { |
|
634 | 634 | |
635 | - $r->group('bar', function ($r) { |
|
635 | + $r->group('bar', function($r) { |
|
636 | 636 | |
637 | - $r->bind('{var1}', function () { |
|
637 | + $r->bind('{var1}', function() { |
|
638 | 638 | }); |
639 | 639 | }); |
640 | 640 | }); |
641 | 641 | }); |
642 | - it("respects url's host constraint", function () { |
|
642 | + it("respects url's host constraint", function() { |
|
643 | 643 | |
644 | 644 | |
645 | 645 | $r = $this->router; |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | 'var1' => 'baz' |
650 | 650 | ]); |
651 | 651 | }); |
652 | - it("throws an exception when the host does not match", function () { |
|
652 | + it("throws an exception when the host does not match", function() { |
|
653 | 653 | |
654 | 654 | |
655 | - $closure = function () { |
|
655 | + $closure = function() { |
|
656 | 656 | |
657 | 657 | $r = $this->router; |
658 | 658 | $route = $r->route('http://bar.hello.foo/foo/bar/baz', 'GET'); |
@@ -660,23 +660,23 @@ discard block |
||
660 | 660 | expect($closure)->toThrow(new RouteNotFoundException("No route found for `http:bar.hello.foo:GET:/foo/bar/baz`.")); |
661 | 661 | }); |
662 | 662 | }); |
663 | - context("with a scheme constraint", function () { |
|
663 | + context("with a scheme constraint", function() { |
|
664 | 664 | |
665 | 665 | |
666 | - beforeEach(function () { |
|
666 | + beforeEach(function() { |
|
667 | 667 | |
668 | 668 | |
669 | 669 | $r = $this->router; |
670 | - $r->group('foo', ['scheme' => 'http'], function ($r) { |
|
670 | + $r->group('foo', ['scheme' => 'http'], function($r) { |
|
671 | 671 | |
672 | - $r->group('bar', function ($r) { |
|
672 | + $r->group('bar', function($r) { |
|
673 | 673 | |
674 | - $r->bind('{var1}', function () { |
|
674 | + $r->bind('{var1}', function() { |
|
675 | 675 | }); |
676 | 676 | }); |
677 | 677 | }); |
678 | 678 | }); |
679 | - it("respects url's scheme constraint", function () { |
|
679 | + it("respects url's scheme constraint", function() { |
|
680 | 680 | |
681 | 681 | |
682 | 682 | $r = $this->router; |
@@ -685,10 +685,10 @@ discard block |
||
685 | 685 | 'var1' => 'baz' |
686 | 686 | ]); |
687 | 687 | }); |
688 | - it("throws an exception when route is not found", function () { |
|
688 | + it("throws an exception when route is not found", function() { |
|
689 | 689 | |
690 | 690 | |
691 | - $closure = function () { |
|
691 | + $closure = function() { |
|
692 | 692 | |
693 | 693 | $r = $this->router; |
694 | 694 | $route = $r->route('https://domain.com/foo/bar/baz', 'GET'); |
@@ -696,25 +696,25 @@ discard block |
||
696 | 696 | expect($closure)->toThrow(new RouteNotFoundException("No route found for `https:domain.com:GET:/foo/bar/baz`.")); |
697 | 697 | }); |
698 | 698 | }); |
699 | - it("concats namespace values", function () { |
|
699 | + it("concats namespace values", function() { |
|
700 | 700 | |
701 | 701 | |
702 | 702 | $r = $this->router; |
703 | - $r->group('foo', ['namespace' => 'My'], function ($r) { |
|
703 | + $r->group('foo', ['namespace' => 'My'], function($r) { |
|
704 | 704 | |
705 | - $r->group('bar', ['namespace' => 'Name'], function ($r) { |
|
705 | + $r->group('bar', ['namespace' => 'Name'], function($r) { |
|
706 | 706 | |
707 | - $r->bind('{var1}', ['namespace' => 'Space'], function () { |
|
707 | + $r->bind('{var1}', ['namespace' => 'Space'], function() { |
|
708 | 708 | }); |
709 | 709 | }); |
710 | 710 | }); |
711 | 711 | $route = $r->route('foo/bar/baz', 'GET'); |
712 | 712 | expect($route->namespace)->toBe('My\Name\Space\\'); |
713 | 713 | }); |
714 | - it("throws an exception when the handler is not a closure", function () { |
|
714 | + it("throws an exception when the handler is not a closure", function() { |
|
715 | 715 | |
716 | 716 | |
717 | - $closure = function () { |
|
717 | + $closure = function() { |
|
718 | 718 | |
719 | 719 | $r = $this->router; |
720 | 720 | $r->group('foo', 'substr'); |
@@ -722,24 +722,24 @@ discard block |
||
722 | 722 | expect($closure)->toThrow(new RouterException("The handler needs to be an instance of `Closure` or implements the `__invoke()` magic method.")); |
723 | 723 | }); |
724 | 724 | }); |
725 | - describe("->middleware()", function () { |
|
725 | + describe("->middleware()", function() { |
|
726 | 726 | |
727 | 727 | |
728 | - it("returns global middleware", function () { |
|
728 | + it("returns global middleware", function() { |
|
729 | 729 | |
730 | 730 | |
731 | 731 | $r = $this->router; |
732 | - $mw1 = function ($request, $response, $next) { |
|
732 | + $mw1 = function($request, $response, $next) { |
|
733 | 733 | |
734 | - return '1' . $next() . '1'; |
|
734 | + return '1'.$next().'1'; |
|
735 | 735 | }; |
736 | - $mw2 = function ($request, $response, $next) { |
|
736 | + $mw2 = function($request, $response, $next) { |
|
737 | 737 | |
738 | - return '2' . $next() . '2'; |
|
738 | + return '2'.$next().'2'; |
|
739 | 739 | }; |
740 | 740 | $r->apply($mw1, $mw2); |
741 | 741 | |
742 | - $next = function () { |
|
742 | + $next = function() { |
|
743 | 743 | return ''; |
744 | 744 | }; |
745 | 745 | $generator = $r->middleware(); |
@@ -750,21 +750,21 @@ discard block |
||
750 | 750 | expect($actual1(null, null, $next))->toBe('11'); |
751 | 751 | }); |
752 | 752 | }); |
753 | - describe("->apply()", function () { |
|
753 | + describe("->apply()", function() { |
|
754 | 754 | |
755 | 755 | |
756 | - it("applies middlewares globally", function () { |
|
756 | + it("applies middlewares globally", function() { |
|
757 | 757 | |
758 | 758 | |
759 | 759 | $r = $this->router; |
760 | - $r->apply(function ($request, $response, $next) { |
|
760 | + $r->apply(function($request, $response, $next) { |
|
761 | 761 | |
762 | - return '1' . $next() . '1'; |
|
763 | - })->apply(function ($request, $response, $next) { |
|
762 | + return '1'.$next().'1'; |
|
763 | + })->apply(function($request, $response, $next) { |
|
764 | 764 | |
765 | - return '2' . $next() . '2'; |
|
765 | + return '2'.$next().'2'; |
|
766 | 766 | }); |
767 | - $route = $r->bind('/foo/bar', function ($route) { |
|
767 | + $route = $r->bind('/foo/bar', function($route) { |
|
768 | 768 | |
769 | 769 | return 'A'; |
770 | 770 | }); |
@@ -772,27 +772,27 @@ discard block |
||
772 | 772 | $actual = $route->dispatch(); |
773 | 773 | expect($actual)->toBe('21A12'); |
774 | 774 | }); |
775 | - it("applies middlewares globally and per groups", function () { |
|
775 | + it("applies middlewares globally and per groups", function() { |
|
776 | 776 | |
777 | 777 | |
778 | 778 | $r = $this->router; |
779 | - $r->apply(function ($request, $response, $next) { |
|
779 | + $r->apply(function($request, $response, $next) { |
|
780 | 780 | |
781 | - return '1' . $next() . '1'; |
|
781 | + return '1'.$next().'1'; |
|
782 | 782 | }); |
783 | - $r->bind('foo/{foo}', ['name' => 'foo'], function () { |
|
783 | + $r->bind('foo/{foo}', ['name' => 'foo'], function() { |
|
784 | 784 | |
785 | 785 | return 'A'; |
786 | 786 | }); |
787 | - $r->group('bar', function ($r) { |
|
787 | + $r->group('bar', function($r) { |
|
788 | 788 | |
789 | - $r->bind('{bar}', ['name' => 'bar'], function () { |
|
789 | + $r->bind('{bar}', ['name' => 'bar'], function() { |
|
790 | 790 | |
791 | 791 | return 'A'; |
792 | 792 | }); |
793 | - })->apply(function ($request, $response, $next) { |
|
793 | + })->apply(function($request, $response, $next) { |
|
794 | 794 | |
795 | - return '2' . $next() . '2'; |
|
795 | + return '2'.$next().'2'; |
|
796 | 796 | }); |
797 | 797 | $route = $r->route('foo/foo'); |
798 | 798 | $actual = $route->dispatch(); |
@@ -802,15 +802,15 @@ discard block |
||
802 | 802 | expect($actual)->toBe('21A12'); |
803 | 803 | }); |
804 | 804 | }); |
805 | - describe("->strategy()", function () { |
|
805 | + describe("->strategy()", function() { |
|
806 | 806 | |
807 | 807 | |
808 | - it("sets a strategy", function () { |
|
808 | + it("sets a strategy", function() { |
|
809 | 809 | |
810 | 810 | $r = $this->router; |
811 | - $mystrategy = function ($router) { |
|
811 | + $mystrategy = function($router) { |
|
812 | 812 | |
813 | - $router->bind('foo/bar', function () { |
|
813 | + $router->bind('foo/bar', function() { |
|
814 | 814 | |
815 | 815 | return 'Hello World!'; |
816 | 816 | }); |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | $route = $r->route('foo/bar'); |
822 | 822 | expect($route->Pattern())->toBe('/foo/bar'); |
823 | 823 | }); |
824 | - it("unsets a strategy", function () { |
|
824 | + it("unsets a strategy", function() { |
|
825 | 825 | |
826 | 826 | $r = $this->router; |
827 | 827 | |
828 | - $mystrategy = function () { |
|
828 | + $mystrategy = function() { |
|
829 | 829 | }; |
830 | 830 | $r->setStrategy('mystrategy', $mystrategy); |
831 | 831 | expect($r->strategy('mystrategy'))->toBe($mystrategy); |
@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | use Lead\Router\Exception\RouterException; |
8 | 8 | use Lead\Router\Host; |
9 | 9 | |
10 | -describe("Host", function () { |
|
10 | +describe("Host", function() { |
|
11 | 11 | |
12 | 12 | |
13 | - describe("->scheme()", function () { |
|
13 | + describe("->scheme()", function() { |
|
14 | 14 | |
15 | 15 | |
16 | - it("gets/sets the scheme", function () { |
|
16 | + it("gets/sets the scheme", function() { |
|
17 | 17 | |
18 | 18 | |
19 | 19 | $host = new Host(); |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | expect($host->scheme())->toBe('https'); |
23 | 23 | }); |
24 | 24 | }); |
25 | - describe("->pattern()", function () { |
|
25 | + describe("->pattern()", function() { |
|
26 | 26 | |
27 | 27 | |
28 | - it("gets/sets the pattern", function () { |
|
28 | + it("gets/sets the pattern", function() { |
|
29 | 29 | |
30 | 30 | |
31 | 31 | $host = new Host(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | 'domain' => false |
38 | 38 | ]); |
39 | 39 | }); |
40 | - it("updates the regex", function () { |
|
40 | + it("updates the regex", function() { |
|
41 | 41 | |
42 | 42 | |
43 | 43 | $host = new Host(); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | expect($host->setPattern('foo.{domain}.baz'))->toBe($host); |
47 | 47 | expect($host->regex())->toBe('foo\\.([^.]+)\\.baz'); |
48 | 48 | }); |
49 | - it("updates the variables", function () { |
|
49 | + it("updates the variables", function() { |
|
50 | 50 | |
51 | 51 | |
52 | 52 | $host = new Host(); |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | ]); |
61 | 61 | }); |
62 | 62 | }); |
63 | - describe("->match()", function () { |
|
63 | + describe("->match()", function() { |
|
64 | 64 | |
65 | 65 | |
66 | - it("returns `true` when host & scheme matches", function () { |
|
66 | + it("returns `true` when host & scheme matches", function() { |
|
67 | 67 | |
68 | 68 | |
69 | 69 | $host = new Host(['pattern' => 'foo.{domain}.bar', 'scheme' => 'https']); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | expect($host->match(['scheme' => 'https', 'host' => 'biz.bar.baz'], $variables))->toBe(false); |
73 | 73 | expect($host->match(['scheme' => 'http', 'host' => 'foo.baz.bar'], $variables))->toBe(false); |
74 | 74 | }); |
75 | - it("returns `true` when host matches with a wildcard as host's scheme", function () { |
|
75 | + it("returns `true` when host matches with a wildcard as host's scheme", function() { |
|
76 | 76 | |
77 | 77 | |
78 | 78 | $host = new Host(['pattern' => 'foo.{domain}.bar', 'scheme' => 'https']); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | expect($variables)->toBe(['domain' => 'baz']); |
81 | 81 | expect($host->match(['scheme' => '*', 'host' => 'biz.baz.bar'], $variables))->toBe(false); |
82 | 82 | }); |
83 | - it("returns `true` when host matches with a wildcard as request's scheme", function () { |
|
83 | + it("returns `true` when host matches with a wildcard as request's scheme", function() { |
|
84 | 84 | |
85 | 85 | |
86 | 86 | $host = new Host(['pattern' => 'foo.{domain}.bar', 'scheme' => '*']); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | expect($variables)->toBe(['domain' => 'baz']); |
89 | 89 | expect($host->match(['scheme' => 'https', 'host' => 'biz.baz.bar'], $variables))->toBe(false); |
90 | 90 | }); |
91 | - it("returns `true` when scheme matches with a wildcard as host's pattern", function () { |
|
91 | + it("returns `true` when scheme matches with a wildcard as host's pattern", function() { |
|
92 | 92 | |
93 | 93 | |
94 | 94 | $host = new Host(['pattern' => '*', 'scheme' => 'http']); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | expect($variables)->toBe([]); |
97 | 97 | expect($host->match(['scheme' => 'https', 'host' => 'foo.baz.bar'], $variables))->toBe(false); |
98 | 98 | }); |
99 | - it("returns `true` when scheme matches with a wildcard as request's pattern", function () { |
|
99 | + it("returns `true` when scheme matches with a wildcard as request's pattern", function() { |
|
100 | 100 | |
101 | 101 | |
102 | 102 | $host = new Host(['pattern' => 'foo.{domain}.bar', 'scheme' => 'http']); |
@@ -105,24 +105,24 @@ discard block |
||
105 | 105 | expect($host->match(['scheme' => 'https', 'host' => '*'], $variables))->toBe(false); |
106 | 106 | }); |
107 | 107 | }); |
108 | - describe("->link()", function () { |
|
108 | + describe("->link()", function() { |
|
109 | 109 | |
110 | 110 | |
111 | - it("builds an host link", function () { |
|
111 | + it("builds an host link", function() { |
|
112 | 112 | |
113 | 113 | |
114 | 114 | $host = new Host(['pattern' => 'www.{domain}.com', 'scheme' => 'https']); |
115 | 115 | $link = $host->link(['domain' => 'example']); |
116 | 116 | expect($link)->toBe('https://www.example.com'); |
117 | 117 | }); |
118 | - it("builds a scheme less host link", function () { |
|
118 | + it("builds a scheme less host link", function() { |
|
119 | 119 | |
120 | 120 | |
121 | 121 | $host = new Host(['pattern' => 'www.{domain}.com']); |
122 | 122 | $link = $host->link(['domain' => 'example']); |
123 | 123 | expect($link)->toBe('//www.example.com'); |
124 | 124 | }); |
125 | - it("overrides scheme when passed as parameter", function () { |
|
125 | + it("overrides scheme when passed as parameter", function() { |
|
126 | 126 | |
127 | 127 | |
128 | 128 | $host = new Host(['pattern' => 'www.{domain}.com']); |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ]); |
132 | 132 | expect($link)->toBe('http://www.example.com'); |
133 | 133 | }); |
134 | - it("processes complex pattern", function () { |
|
134 | + it("processes complex pattern", function() { |
|
135 | 135 | |
136 | 136 | |
137 | 137 | $host = new Host(['pattern' => '[{subdomains}.]*{domain}.com', 'scheme' => 'https']); |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | 'domain' => 'example' |
146 | 146 | ]))->toBe('https://a.b.c.example.com'); |
147 | 147 | }); |
148 | - it("throws an exception when variables are missing", function () { |
|
148 | + it("throws an exception when variables are missing", function() { |
|
149 | 149 | |
150 | 150 | |
151 | - $closure = function () { |
|
151 | + $closure = function() { |
|
152 | 152 | |
153 | 153 | $host = new Host(['pattern' => 'www.{domain}.com']); |
154 | 154 | $link = $host->link(); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | return false; |
220 | 220 | } |
221 | 221 | |
222 | - if (!preg_match('~^' . $this->regex() . '$~', $host, $matches)) { |
|
222 | + if (!preg_match('~^'.$this->regex().'$~', $host, $matches)) { |
|
223 | 223 | $hostVariables = null; |
224 | 224 | return false; |
225 | 225 | } |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | $options['host'] = $this->_link($this->token(), $params); |
246 | 246 | } |
247 | 247 | |
248 | - $scheme = $options['scheme'] !== '*' ? $options['scheme'] . '://' : '//'; |
|
248 | + $scheme = $options['scheme'] !== '*' ? $options['scheme'].'://' : '//'; |
|
249 | 249 | |
250 | - return $scheme . $options['host']; |
|
250 | + return $scheme.$options['host']; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |