Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       100.00%  | 
       5 / 5  | 
               | 
       100.00%  | 
       2 / 2  | 
       CRAP |         | 
       100.00%  | 
       1 / 1  | 
      
| StringValueObjectWithRegexFaker |         | 
       100.00%  | 
       5 / 5  | 
               | 
       100.00%  | 
       2 / 2  | 
       2 |         | 
       100.00%  | 
       1 / 1  | 
      
| supports |         | 
       100.00%  | 
       1 / 1  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| fakeFor |         | 
       100.00%  | 
       4 / 4  | 
               | 
       100.00%  | 
       1 / 1  | 
       1 | |||
| 1 | <?php | 
| 2 | namespace Apie\Faker\Fakers; | 
| 3 | |
| 4 | use Apie\Core\RegexUtils; | 
| 5 | use Apie\Core\ValueObjects\Interfaces\HasRegexValueObjectInterface; | 
| 6 | use Apie\Faker\Interfaces\ApieClassFaker; | 
| 7 | use Faker\Generator; | 
| 8 | use ReflectionClass; | 
| 9 | use RegRev\RegRev; | 
| 10 | |
| 11 | /** @implements ApieClassFaker<HasRegexValueObjectInterface> */ | 
| 12 | class StringValueObjectWithRegexFaker implements ApieClassFaker | 
| 13 | { | 
| 14 | public function supports(ReflectionClass $class): bool | 
| 15 | { | 
| 16 | return $class->implementsInterface(HasRegexValueObjectInterface::class); | 
| 17 | } | 
| 18 | |
| 19 | public function fakeFor(Generator $generator, ReflectionClass $class): HasRegexValueObjectInterface | 
| 20 | { | 
| 21 | $className = $class->name; | 
| 22 | $regularExpressionWithDelimiter = $className::getRegularExpression(); | 
| 23 | $regex = RegexUtils::removeDelimiters($regularExpressionWithDelimiter); | 
| 24 | return $className::fromNative(RegRev::generate($regex)); | 
| 25 | } | 
| 26 | } |