Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
66.67% |
6 / 9 |
|
50.00% |
3 / 6 |
CRAP | |
0.00% |
0 / 1 |
| UnaryOperationExpression | |
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\Enums\UnaryOperator; |
| 6 | use Apie\TypescriptCodeBuilder\Lists\JavascriptIdentifierList; |
| 7 | use Apie\TypescriptCodeBuilder\TypescriptFileExpressionInterface; |
| 8 | use Faker\Generator; |
| 9 | |
| 10 | #[FakeMethod('createRandom')] |
| 11 | class UnaryOperationExpression implements TypescriptFileExpressionInterface |
| 12 | { |
| 13 | public function __construct(public UnaryOperator $operator, public TypescriptFileExpressionInterface $expression) |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | public function toTypescript(): string |
| 18 | { |
| 19 | return $this->operator->value . ' ' . $this->expression->toTypescript(); |
| 20 | } |
| 21 | public function toJavascript(): string |
| 22 | { |
| 23 | return $this->operator->value . ' ' . $this->expression->toJavascript(); |
| 24 | } |
| 25 | public function providesDefinitions(): JavascriptIdentifierList |
| 26 | { |
| 27 | return new JavascriptIdentifierList(); |
| 28 | } |
| 29 | public function needsDefinitions(): JavascriptIdentifierList |
| 30 | { |
| 31 | return $this->expression->needsDefinitions(); |
| 32 | } |
| 33 | |
| 34 | public static function createRandom(Generator $faker): self |
| 35 | { |
| 36 | return new self( |
| 37 | $faker->fakeClass(UnaryOperator::class), |
| 38 | $faker->fakeClass(ParenthesizedExpression::class) |
| 39 | ); |
| 40 | } |
| 41 | } |