StringLiteral   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 30
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A toResolver() 0 3 1
A toArray() 0 6 1
A __construct() 0 4 1
A getType() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Diezz\YamlToObjectMapper\Resolver\Parser\AST;
4
5
use Diezz\YamlToObjectMapper\Resolver\ArgumentResolver;
6
use Diezz\YamlToObjectMapper\Resolver\ArgumentResolverFactory;
7
use Diezz\YamlToObjectMapper\Resolver\ScalarArgumentResolver;
8
use JetBrains\PhpStorm\ArrayShape;
9
10
class StringLiteral extends ASTNode
11
{
12 16
    public function __construct(
13
        private string $value
14
    )
15
    {
16 16
    }
17
18 16
    public function getType(): string
19
    {
20 16
        return 'StringLiteral';
21
    }
22
23
    public function getValue(): string
24
    {
25
        return $this->value;
26
    }
27
28 16
    #[ArrayShape(['type' => "string", 'value' => "string"])]
29
    public function toArray(): array
30
    {
31
        return [
32 16
            'type'  => $this->getType(),
33 16
            'value' => $this->value,
34
        ];
35
    }
36
37
    public function toResolver(ArgumentResolverFactory $argumentResolverFactory): ArgumentResolver
38
    {
39
        return new ScalarArgumentResolver($this->getValue());
40
    }
41
}
42