Skip to content

Commit efe6bbd

Browse files
authored
Merge pull request #141 from Jagepard/wip
add Attributes
2 parents 98c0d11 + 8c50dec commit efe6bbd

3 files changed

Lines changed: 52 additions & 5 deletions

File tree

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
46
* This Source Code Form is subject to the terms of the Mozilla Public
57
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -9,10 +11,11 @@
911
* @license https://mozilla.org/MPL/2.0/ MPL-2.0
1012
*/
1113

12-
namespace Rudra\Router;
13-
14-
#[\Attribute]
15-
class Routing
14+
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
15+
class AfterMiddleware
1616
{
17-
17+
public function __construct(
18+
public string $name,
19+
public string|null $params = null
20+
) {}
1821
}

‎src/Attributes/Middleware.php‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This Source Code Form is subject to the terms of the Mozilla Public
7+
* License, v. 2.0. If a copy of the MPL was not distributed with this
8+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
9+
*
10+
* @author Korotkov Danila (Jagepard) <jagepard@yandex.ru>
11+
* @license https://mozilla.org/MPL/2.0/ MPL-2.0
12+
*/
13+
14+
namespace Rudra\Router\Attributes;
15+
16+
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
17+
class Middleware
18+
{
19+
public function __construct(
20+
public string $name,
21+
public string|null $params = null
22+
) {}
23+
}

‎src/Attributes/Routing.php‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/**
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* @author Korotkov Danila (Jagepard) <jagepard@yandex.ru>
9+
* @license https://mozilla.org/MPL/2.0/ MPL-2.0
10+
*/
11+
12+
namespace Rudra\Router\Attributes;
13+
14+
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
15+
class Routing
16+
{
17+
public function __construct(
18+
public string $url = '',
19+
public string|array $method = 'GET'
20+
) {}
21+
}

0 commit comments

Comments
 (0)