YAML::parseString()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 3
Bugs 1 Features 1
Metric Value
cc 3
eloc 6
c 3
b 1
f 1
nc 3
nop 1
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Enjoys\Config\Parse;
6
7
use Enjoys\Config\Parse;
8
use Psr\Log\LoggerInterface;
9
use Symfony\Component\Yaml as Symfony;
10
11
/**
12
 * @see https://symfony.com/doc/current/components/yaml.htm
13
 * @psalm-suppress MixedReturnStatement, MixedInferredReturnType
14
 * @author Enjoys
15
 */
16
class YAML extends Parse
17
{
18
19
    /**
20
     * {@inheritDoc}
21
     * @psalm-suppress ReservedWord, InvalidReturnStatement
22
     */
23 7
    protected function parseString(string $input)
24
    {
25
        try {
26 7
            return Symfony\Yaml::parse($input, (int)$this->getOption('flags', 0));
27 2
        } catch (Symfony\Exception\ParseException $e) {
28 2
            if ($this->logger instanceof LoggerInterface) {
29 2
                $this->logger->error($e->getMessage());
30
            }
31 2
            return null;
32
        }
33
    }
34
35
}
36