Skip to content

Commit 025de68

Browse files
committed
new methods
1 parent f052563 commit 025de68

File tree

2 files changed

+56
-17
lines changed

2 files changed

+56
-17
lines changed

src/Route.php

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
use Psr\Http\Server\MiddlewareInterface;
2020
use Psr\Http\Server\RequestHandlerInterface;
2121
use Sunrise\Http\Router\RequestHandler\QueueableRequestHandler;
22+
use ReflectionClass;
23+
use ReflectionMethod;
24+
use Reflector;
2225

2326
/**
2427
* Import functions
@@ -29,7 +32,7 @@
2932
/**
3033
* Route
3134
*
32-
* Use the factory to create this class.
35+
* Use the {@see RouteFactory} factory to create this class.
3336
*/
3437
class Route implements RouteInterface
3538
{
@@ -46,22 +49,10 @@ class Route implements RouteInterface
4649
*
4750
* @var string
4851
*
49-
* @deprecated 2.9.0 Use the following construction: `$request->getAttribute('@route')->getName()`.
52+
* @deprecated 2.9.0
5053
*/
5154
public const ATTR_NAME_FOR_ROUTE_NAME = '@route-name';
5255

53-
/**
54-
* Global patterns
55-
*
56-
* @var array<string, string>
57-
*
58-
* @since 2.9.0
59-
*/
60-
public static $patterns = [
61-
'@slug' => '[0-9a-z-]+',
62-
'@uuid' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
63-
];
64-
6556
/**
6657
* The route name
6758
*
@@ -72,7 +63,7 @@ class Route implements RouteInterface
7263
/**
7364
* The route host
7465
*
75-
* @var null|string
66+
* @var string|null
7667
*/
7768
private $host = null;
7869

@@ -132,6 +123,13 @@ class Route implements RouteInterface
132123
*/
133124
private $tags = [];
134125

126+
/**
127+
* The route holder
128+
*
129+
* @var ReflectionClass|ReflectionMethod|null
130+
*/
131+
private $holder = null;
132+
135133
/**
136134
* Constructor of the class
137135
*
@@ -238,6 +236,14 @@ public function getTags() : array
238236
return $this->tags;
239237
}
240238

239+
/**
240+
* {@inheritdoc}
241+
*/
242+
public function getHolder() : ?Reflector
243+
{
244+
return $this->holder;
245+
}
246+
241247
/**
242248
* {@inheritdoc}
243249
*/
@@ -342,6 +348,16 @@ public function setTags(string ...$tags) : RouteInterface
342348
return $this;
343349
}
344350

351+
/**
352+
* {@inheritdoc}
353+
*/
354+
public function setHolder(?Reflector $holder) : RouteInterface
355+
{
356+
$this->holder = $holder;
357+
358+
return $this;
359+
}
360+
345361
/**
346362
* {@inheritdoc}
347363
*/

src/RouteInterface.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717
use Psr\Http\Server\MiddlewareInterface;
1818
use Psr\Http\Server\RequestHandlerInterface;
19+
use ReflectionClass;
20+
use ReflectionMethod;
21+
use Reflector;
1922

2023
/**
2124
* RouteInterface
@@ -33,7 +36,7 @@ public function getName() : string;
3336
/**
3437
* Gets the route host
3538
*
36-
* @return null|string
39+
* @return string|null
3740
*
3841
* @since 2.6.0
3942
*/
@@ -101,6 +104,15 @@ public function getDescription() : string;
101104
*/
102105
public function getTags() : array;
103106

107+
/**
108+
* Gets the route holder
109+
*
110+
* @return ReflectionClass|ReflectionMethod|null
111+
*
112+
* @since 2.10.0
113+
*/
114+
public function getHolder() : ?Reflector;
115+
104116
/**
105117
* Sets the given name to the route
106118
*
@@ -113,7 +125,7 @@ public function setName(string $name) : RouteInterface;
113125
/**
114126
* Sets the given host to the route
115127
*
116-
* @param null|string $host
128+
* @param string|null $host
117129
*
118130
* @return RouteInterface
119131
*
@@ -199,6 +211,17 @@ public function setDescription(string $description) : RouteInterface;
199211
*/
200212
public function setTags(string ...$tags) : RouteInterface;
201213

214+
/**
215+
* Sets the given holder to the route
216+
*
217+
* @param ReflectionClass|ReflectionMethod|null $holder
218+
*
219+
* @return RouteInterface
220+
*
221+
* @since 2.10.0
222+
*/
223+
public function setHolder(?Reflector $holder) : RouteInterface;
224+
202225
/**
203226
* Adds the given prefix to the route path
204227
*

0 commit comments

Comments
 (0)