YamlDecoder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A decode() 0 6 1
A getMimeType() 0 4 1
1
<?php
2
namespace Michaels\Manager\Decoders;
3
4
use Michaels\Manager\Contracts\DecoderInterface;
5
use Symfony\Component\Yaml\Parser;
6
7
/**
8
 * SerializationTypeNotSupportedException
9
 * @package Michaels\Manager
10
 */
11
class YamlDecoder implements DecoderInterface
12
{
13
    /** @var array Decoded data */
14
    protected $arrayData = [];
15
16
    /**
17
     * This is the method, which does the decoding work.
18
     *
19
     * @param $data
20
     * @return array
21
     */
22
    public function decode($data)
23
    {
24
        $parser = new Parser();
25
        $this->arrayData = (array) $parser->parse($data);
26
        return $this->arrayData;
27
    }
28
29
    /**
30
     * The data returned is the actual file extensions supported for the files to decode.
31
     * For instance, if you want to decode Yaml files with the extensions ".yml" and ".yaml",
32
     * then you want to set the return array to ['yaml', 'yml'].
33
     *
34
     * @return array
35
     */
36
    public function getMimeType()
37
    {
38
        return ['yaml', 'yml'];
39
    }
40
}
41