Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       100.00%  | 
       7 / 7  | 
               | 
       100.00%  | 
       2 / 2  | 
       CRAP |         | 
       100.00%  | 
       1 / 1  | 
      
| ItemHashmapFaker |         | 
       100.00%  | 
       7 / 7  | 
               | 
       100.00%  | 
       2 / 2  | 
       4 |         | 
       100.00%  | 
       1 / 1  | 
      
| supports |         | 
       100.00%  | 
       1 / 1  | 
               | 
       100.00%  | 
       1 / 1  | 
       2 | |||
| fakeFor |         | 
       100.00%  | 
       6 / 6  | 
               | 
       100.00%  | 
       1 / 1  | 
       2 | |||
| 1 | <?php | 
| 2 | |
| 3 | namespace Apie\Faker\Fakers; | 
| 4 | |
| 5 | use Apie\Core\Lists\ItemHashmap; | 
| 6 | use Apie\Faker\Interfaces\ApieClassFaker; | 
| 7 | use Faker\Generator; | 
| 8 | use ReflectionClass; | 
| 9 | |
| 10 | /** @implements ApieClassFaker<ItemHashmap> */ | 
| 11 | class ItemHashmapFaker implements ApieClassFaker | 
| 12 | { | 
| 13 | public function supports(ReflectionClass $class): bool | 
| 14 | { | 
| 15 | return $class->isSubclassOf(ItemHashmap::class) || $class->name === ItemHashmap::class; | 
| 16 | } | 
| 17 | |
| 18 | public function fakeFor(Generator $generator, ReflectionClass $class): object | 
| 19 | { | 
| 20 | $returnType = $class->getMethod('offsetGet')->getReturnType(); | 
| 21 | $itemCount = $generator->numberBetween(1, 4); | 
| 22 | $arguments = []; | 
| 23 | for ($i = 0; $i < $itemCount; $i++) { | 
| 24 | $arguments[$generator->word()] = $generator->fakeFromType($returnType); | 
| 25 | } | 
| 26 | return $class->newInstance($arguments); | 
| 27 | } | 
| 28 | } |