Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
57.14% covered (warning)
57.14%
4 / 7
50.00% covered (danger)
50.00%
3 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
RawTypeDefinition
57.14% covered (warning)
57.14%
4 / 7
50.00% covered (danger)
50.00%
3 / 6
8.83
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 createRandom
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 toTypescript
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toJavascript
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 providesDefinitions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 needsDefinitions
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\TypescriptCodeBuilder\Dto\Typehints;
3
4use Apie\Core\Attributes\FakeMethod;
5use Apie\Core\Attributes\Optional;
6use Apie\TypescriptCodeBuilder\Enums\TypescriptType;
7use Apie\TypescriptCodeBuilder\Lists\JavascriptIdentifierList;
8use Apie\TypescriptCodeBuilder\TypescriptTypeDeclarationInterface;
9use Faker\Generator;
10
11#[FakeMethod('createRandom')]
12class RawTypeDefinition implements TypescriptTypeDeclarationInterface
13{
14    #[Optional]
15    public JavascriptIdentifierList $providesDefinition;
16
17    #[Optional]
18    public JavascriptIdentifierList $needsDefinition;
19
20    public function __construct(
21        public string $typescriptCode,
22        array $providesDefinition = [],
23        array $needsDefinition = [],
24    ) {
25        $this->providesDefinition = new JavascriptIdentifierList($providesDefinition);
26        $this->needsDefinition = new JavascriptIdentifierList($needsDefinition);
27    }
28
29    public static function createRandom(Generator $faker): self
30    {
31        return new RawTypeDefinition($faker->fakeClass(TypescriptType::class));
32    }
33
34    public function toTypescript(): string
35    {
36        return $this->typescriptCode;
37    }
38    public function toJavascript(): string
39    {
40        return '';
41    }
42    public function providesDefinitions(bool $applyBlockScope): JavascriptIdentifierList
43    {
44        return $this->providesDefinition;
45    }
46    public function needsDefinitions(): JavascriptIdentifierList
47    {
48        return $this->needsDefinition;
49    }
50}