Passed
Branch master (5fcf14)
by Adrian Florin
03:29 queued 53s
created

YamlContent::getArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of the NeedleProject\FileIo package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
namespace NeedleProject\FileIo\Content;
9
10
use Symfony\Component\Yaml\Yaml;
11
12
/**
13
 * Class YamlContent
14
 *
15
 * @package NeedleProject\FileIo\Content
16
 */
17
class YamlContent implements ArrayContentInterface
18
{
19
    /**
20
     * @var null|string
21
     */
22
    private $content = null;
23
24
    /**
25
     * Content constructor.
26
     *
27
     * @param string $content
28
     */
29 1
    public function __construct(string $content)
30
    {
31 1
        $this->content = $content;
32 1
    }
33
34
    /**
35
     * @return string
36
     */
37
    public function get(): string
38
    {
39
        return $this->content;
40
    }
41
42
    /**
43
     * Return the content as an array
44
     *
45
     * @return array
46
     * @throws \NeedleProject\FileIo\Exception\ContentException
47
     */
48 1
    public function getArray(): array
49
    {
50 1
        return Yaml::parse($this->content);
51
    }
52
}
53