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