YAML::toYAML()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace einfach\representer\serializer;
3
4
use Symfony\Component\Yaml\Yaml as YamlDumper;
5
6
/**
7
 * Class JSON
8
 *
9
 * @package einfach\representer\serializer
10
 *
11
 */
12
trait YAML
13
{
14 2
    public function toYAML()
15
    {
16 2
        return YamlDumper::dump($this->getRepresentation());
17
    }
18
19 1
    public function fromYAML($string)
20
    {
21 1
        $projection = YamlDumper::parse($string);
22 1
        return $this->getReverseRepresentation($projection);
23
    }
24
25
    protected abstract function getRepresentation();
26
27
    protected abstract function getReverseRepresentation($projection);
28
}
29