Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PasswordValueObjectFaker
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 supports
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 fakeFor
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Faker\Fakers;
3
4use Apie\Core\Randomizer\RandomizerFromFaker;
5use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface;
6use Apie\Core\ValueObjects\IsPasswordValueObject;
7use Apie\Faker\Interfaces\ApieClassFaker;
8use Faker\Generator;
9use ReflectionClass;
10
11/** @implements ApieClassFaker<ValueObjectInterface> */
12class PasswordValueObjectFaker implements ApieClassFaker
13{
14    public function supports(ReflectionClass $class): bool
15    {
16        return $class->implementsInterface(ValueObjectInterface::class) && in_array(IsPasswordValueObject::class, $class->getTraitNames());
17    }
18
19    public function fakeFor(Generator $generator, ReflectionClass $class): ValueObjectInterface
20    {
21        $className = $class->name;
22        return $className::createRandom(new RandomizerFromFaker($generator));
23    }
24}