Skip to content

Commit

Permalink
v3
Browse files Browse the repository at this point in the history
  • Loading branch information
fenric committed Oct 25, 2024
1 parent 7c896fc commit 564e5b0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Annotation/PatternAsciiSlug.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* It's free open-source software released under the MIT License.
*
* @author Anatoly Nekhay <afenric@gmail.com>
* @copyright Copyright (c) 2018, Anatoly Nekhay
* @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
* @link https://github.com/sunrise-php/http-router
*/

declare(strict_types=1);

namespace Sunrise\Http\Router\Annotation;

use Attribute;
use Sunrise\Http\Router\Dictionary\VariablePattern;

/**
* @since 3.0.0
*/
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
final class PatternAsciiSlug extends Pattern
{
public function __construct(string $variableName)
{
parent::__construct($variableName, VariablePattern::ASCII_SLUG);
}
}
29 changes: 29 additions & 0 deletions src/Annotation/PatternPositiveInt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* It's free open-source software released under the MIT License.
*
* @author Anatoly Nekhay <afenric@gmail.com>
* @copyright Copyright (c) 2018, Anatoly Nekhay
* @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
* @link https://github.com/sunrise-php/http-router
*/

declare(strict_types=1);

namespace Sunrise\Http\Router\Annotation;

use Attribute;
use Sunrise\Http\Router\Dictionary\VariablePattern;

/**
* @since 3.0.0
*/
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
final class PatternPositiveInt extends Pattern
{
public function __construct(string $variableName)
{
parent::__construct($variableName, VariablePattern::POSITIVE_INT);
}
}
2 changes: 2 additions & 0 deletions src/Dictionary/VariablePattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
*/
final class VariablePattern
{
public const POSITIVE_INT = '[0-9]+';
public const ASCII_SLUG = '[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*';
public const UUID = '[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}';
}

0 comments on commit 564e5b0

Please sign in to comment.