Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
87.50% |
7 / 8 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| TypescriptDeclarationList | |
87.50% |
7 / 8 |
|
50.00% |
1 / 2 |
3.02 | |
0.00% |
0 / 1 |
| offsetGet | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| createRandom | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\TypescriptCodeBuilder\Lists; |
| 3 | |
| 4 | use Apie\Core\Attributes\FakeMethod; |
| 5 | use Apie\Core\Lists\ItemList; |
| 6 | use Apie\TypescriptCodeBuilder\Dto\Typehints\IdentifierTypeDefinition; |
| 7 | use Apie\TypescriptCodeBuilder\Dto\Typehints\LiteralTypeDefinition; |
| 8 | use Apie\TypescriptCodeBuilder\Enums\TypescriptType; |
| 9 | use Apie\TypescriptCodeBuilder\TypescriptTypeDeclarationInterface; |
| 10 | use Faker\Generator; |
| 11 | |
| 12 | #[FakeMethod('createRandom')] |
| 13 | class TypescriptDeclarationList extends ItemList |
| 14 | { |
| 15 | public function offsetGet(mixed $offset): TypescriptTypeDeclarationInterface |
| 16 | { |
| 17 | return parent::offsetGet($offset); |
| 18 | } |
| 19 | |
| 20 | public static function createRandom(Generator $faker): self |
| 21 | { |
| 22 | $list = []; |
| 23 | $count = $faker->numberBetween(0, 3); |
| 24 | for ($i = 0; $i < $count; $i++) { |
| 25 | $list[] = $faker->fakeClass( |
| 26 | $faker->randomElement([IdentifierTypeDefinition::class,TypescriptType::class, LiteralTypeDefinition::class]) |
| 27 | ); |
| 28 | } |
| 29 | return new TypescriptDeclarationList($list); |
| 30 | } |
| 31 | } |