Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
66.67% |
6 / 9 |
|
50.00% |
3 / 6 |
CRAP | |
0.00% |
0 / 1 |
| PropertyAccessExpression | |
66.67% |
6 / 9 |
|
50.00% |
3 / 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 | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| providesDefinitions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| needsDefinitions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| createRandom | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\TypescriptCodeBuilder\Dto\Expressions; |
| 3 | |
| 4 | use Apie\Core\Attributes\FakeMethod; |
| 5 | use Apie\TypescriptCodeBuilder\Lists\JavascriptIdentifierList; |
| 6 | use Apie\TypescriptCodeBuilder\TypescriptFileExpressionInterface; |
| 7 | use Apie\TypescriptCodeBuilder\ValueObjects\JavascriptIdentifier; |
| 8 | use Faker\Generator; |
| 9 | |
| 10 | #[FakeMethod('createRandom')] |
| 11 | class PropertyAccessExpression implements TypescriptFileExpressionInterface |
| 12 | { |
| 13 | public function __construct( |
| 14 | public TypescriptFileExpressionInterface $object, |
| 15 | public JavascriptIdentifier $property |
| 16 | ) { |
| 17 | } |
| 18 | |
| 19 | public function toTypescript(): string |
| 20 | { |
| 21 | return $this->object->toTypescript() . '.' . $this->property->toNative(); |
| 22 | } |
| 23 | public function toJavascript(): string |
| 24 | { |
| 25 | return $this->object->toJavascript() . '.' . $this->property->toNative(); |
| 26 | } |
| 27 | public function providesDefinitions(): JavascriptIdentifierList |
| 28 | { |
| 29 | return new JavascriptIdentifierList(); |
| 30 | } |
| 31 | public function needsDefinitions(): JavascriptIdentifierList |
| 32 | { |
| 33 | return $this->object->needsDefinitions(); |
| 34 | } |
| 35 | |
| 36 | public static function createRandom(Generator $faker): self |
| 37 | { |
| 38 | return new self( |
| 39 | $faker->fakeClass(IdentifierExpression::class), |
| 40 | JavascriptIdentifier::createRandom($faker) |
| 41 | ); |
| 42 | } |
| 43 | } |