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

YamlFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 41
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A format() 0 4 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