Skip to content

Commit

Permalink
make method for ParseRegex
Browse files Browse the repository at this point in the history
  • Loading branch information
Triplkrypl committed Jul 26, 2024
1 parent 60658ec commit 1e0cc01
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Rule/String/ParseRegex.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SimpleAsFuck\Validator\Rule\String;

use SimpleAsFuck\Validator\Factory\Exception;
use SimpleAsFuck\Validator\Factory\UnexpectedValueException;
use SimpleAsFuck\Validator\Model\RuleChain;
use SimpleAsFuck\Validator\Model\Validated;
use SimpleAsFuck\Validator\Model\ValueMust;
Expand All @@ -15,6 +16,18 @@
*/
final class ParseRegex extends Rule
{
/**
* @param non-empty-string $pattern cool example: '/(?P<matchKey>.*)/'
* @param string $value
* @param PREG_OFFSET_CAPTURE|PREG_UNMATCHED_AS_NULL|768|0 $flags
* @param non-empty-string $valueName
*/
public static function make(string $pattern, string $value, int $flags = 0, string $valueName = 'variable'): ParseRegex
{
/** @var mixed $value */
return new ParseRegex(new UnexpectedValueException(), new RuleChain(), new Validated($value), $valueName, $pattern, $flags);
}

/**
* @param RuleChain<string> $ruleChain
* @param Validated<mixed> $validated
Expand Down

0 comments on commit 1e0cc01

Please sign in to comment.