Passed
Push — master ( 0e7d9c...4d448d )
by Dominik
02:31
created

YamlFormatter::format()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization\Formatter;
6
7
use Symfony\Component\Yaml\Yaml;
8
9
final class YamlFormatter implements FormatterInterface
10
{
11
    /**
12
     * @var int
13
     */
14
    private $inline;
15
16
    /**
17
     * @var int
18
     */
19
    private $indent;
20
21
    /**
22
     * @var int
23
     */
24
    private $flags;
25
26
    /**
27
     * YamlFormatter constructor.
28
     *
29
     * @param int $inline
30
     * @param int $indent
31
     * @param int $flags
32
     */
33 1
    public function __construct(int $inline = 2, int $indent = 4, int $flags = 0)
34
    {
35 1
        $this->inline = $inline;
36 1
        $this->indent = $indent;
37 1
        $this->flags = $flags;
38 1
    }
39
40
    /**
41
     * @param array $data
42
     *
43
     * @return string
44
     */
45 1
    public function format(array $data): string
46
    {
47 1
        return Yaml::dump($data, $this->inline, $this->indent, $this->flags);
48
    }
49
}
50