Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
PhpRegularExpression | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
validate | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | namespace Apie\RegexValueObjects; |
3 | |
4 | use Apie\Core\Attributes\Description; |
5 | use Apie\Core\Attributes\FakeMethod; |
6 | use Apie\Core\ValueObjects\Interfaces\StringValueObjectInterface; |
7 | use Apie\Core\ValueObjects\IsStringValueObject; |
8 | use Apie\RegexValueObjects\Exceptions\InvalidPhpRegularExpression; |
9 | |
10 | #[FakeMethod("createRandom")] |
11 | #[Description('Any regular expression that can be parsed with PHP preg_match method.')] |
12 | final class PhpRegularExpression implements StringValueObjectInterface |
13 | { |
14 | use IsStringValueObject; |
15 | use SharedRegularExpression; |
16 | |
17 | public static function validate(string $input): void |
18 | { |
19 | if (false === @preg_match($input, '')) { |
20 | throw new InvalidPhpRegularExpression($input, preg_last_error_msg()); |
21 | } |
22 | } |
23 | } |