YamlUnserialiser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 19
ccs 4
cts 5
cp 0.8
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A unserialise() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of Payload.
5
 *
6
 * (c) DraperStudio <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace DraperStudio\Payload\Unserialisers;
13
14
use DraperStudio\Payload\Contracts\Unserialiser;
15
use DraperStudio\Payload\Utils\Mapper;
16
use Symfony\Component\Yaml\Yaml;
17
18
/**
19
 * Class YamlUnserialiser.
20
 */
21
class YamlUnserialiser implements Unserialiser
22
{
23
    /**
24
     * @param $input
25
     * @param null $class
26
     *
27
     * @return mixed
28
     */
29 6
    public function unserialise($input, $class = null)
30
    {
31 6
        $contents = Yaml::parse($input);
32
33 6
        if (!is_null($class)) {
34
            return (new Mapper())->map($contents, $class);
35
        }
36
37 6
        return $contents;
38
    }
39
}
40