YamlTransformer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 33
rs 10

3 Methods

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