StringLiteral::getType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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