Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
66.67% |
4 / 6 |
|
66.67% |
4 / 6 |
CRAP | |
0.00% |
0 / 1 |
| ArrayTypeDefinition | |
66.67% |
4 / 6 |
|
66.67% |
4 / 6 |
7.33 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toTypescript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toJavascript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| providesDefinitions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| needsDefinitions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| createRandom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\TypescriptCodeBuilder\Dto\Typehints; |
| 3 | |
| 4 | use Apie\Core\Attributes\FakeMethod; |
| 5 | use Apie\TypescriptCodeBuilder\Enums\TypescriptType; |
| 6 | use Apie\TypescriptCodeBuilder\Lists\JavascriptIdentifierList; |
| 7 | use Apie\TypescriptCodeBuilder\TypescriptTypeDeclarationInterface; |
| 8 | use Faker\Generator; |
| 9 | |
| 10 | /** |
| 11 | * Typescript definition for an array type. |
| 12 | */ |
| 13 | #[FakeMethod('createRandom')] |
| 14 | class ArrayTypeDefinition implements TypescriptTypeDeclarationInterface |
| 15 | { |
| 16 | public function __construct( |
| 17 | public TypescriptTypeDeclarationInterface $typehint |
| 18 | ) { |
| 19 | |
| 20 | } |
| 21 | public function toTypescript(): string |
| 22 | { |
| 23 | return $this->typehint->toTypescript() . '[]'; |
| 24 | } |
| 25 | public function toJavascript(): string |
| 26 | { |
| 27 | return ''; |
| 28 | } |
| 29 | public function providesDefinitions(): JavascriptIdentifierList |
| 30 | { |
| 31 | return new JavascriptIdentifierList(); |
| 32 | } |
| 33 | public function needsDefinitions(): JavascriptIdentifierList |
| 34 | { |
| 35 | return $this->typehint->needsDefinitions(); |
| 36 | } |
| 37 | |
| 38 | public static function createRandom(Generator $faker): static |
| 39 | { |
| 40 | return new ArrayTypeDefinition($faker->fakeClass(TypescriptType::class)); |
| 41 | } |
| 42 | } |