Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
80.00% covered (warning)
80.00%
4 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
StringLiteralExpression
80.00% covered (warning)
80.00%
4 / 5
80.00% covered (warning)
80.00%
4 / 5
5.20
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toTypescript
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toJavascript
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 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\Expressions;
3
4use Apie\TypescriptCodeBuilder\Lists\JavascriptIdentifierList;
5use Apie\TypescriptCodeBuilder\TypescriptFileExpressionInterface;
6
7class StringLiteralExpression implements TypescriptFileExpressionInterface
8{
9    public function __construct(public string $value)
10    {
11    }
12
13    public function toTypescript(): string
14    {
15        return json_encode($this->value, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
16    }
17    public function toJavascript(): string
18    {
19        return $this->toTypescript();
20    }
21    public function providesDefinitions(bool $applyBlockScope): JavascriptIdentifierList
22    {
23        return new JavascriptIdentifierList();
24    }
25    public function needsDefinitions(): JavascriptIdentifierList
26    {
27        return new JavascriptIdentifierList();
28    }
29}