YamlTransformer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace DoS\ResourceBundle\Form\DataTransformer;
4
5
use Symfony\Component\Form\DataTransformerInterface;
6
use Symfony\Component\Yaml\Yaml;
7
8
class YamlTransformer implements DataTransformerInterface
9
{
10
    /**
11
     * The level where you switch to inline YAML.
12
     *
13
     * @var int
14
     */
15
    protected $inlineLevel;
16
17
    /**
18
     * @param int $inlineLevel
19
     */
20
    public function __construct($inlineLevel = 10)
21
    {
22
        $this->inlineLevel = $inlineLevel;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function reverseTransform($value)
29
    {
30
        return Yaml::parse($value);
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function transform($value)
37
    {
38
        return Yaml::dump($value, $this->inlineLevel);
39
    }
40
}
41