Test Failed
Push — master ( 5fcf14...625fb6 )
by Adrian Florin
04:15 queued 01:51
created

Content::getObject()   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
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
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
/**
11
 * Class Content
12
 *
13
 * @package NeedleProject\FileIo\Content
14
 * @author Adrian Tilita <[email protected]>
15
 * @copyright 2017 Adrian Tilita
16
 * @license https://opensource.org/licenses/MIT MIT Licence
17
 */
18
class Content implements ContentInterface
19
{
20
    /**
21
     * @var null|string
22
     */
23
    private $content = null;
24
25
    /**
26
     * Content constructor.
27
     *
28
     * @param string $content
29
     */
30 20
    public function __construct(string $content)
31
    {
32 20
        $this->content = $content;
33 20
    }
34
35
    /**
36
     * @return string
37
     */
38 26
    public function get(): string
39
    {
40 26
        return $this->content;
41
    }
42
43
    /**
44
     * Return the content as an array
45
     *
46
     * @return array
47
     * @throws \NeedleProject\FileIo\Exception\ContentException
48
     */
49 4
    public function getArray(): array
50
    {
51 4
        return [$this->content];
52
    }
53
54
    /**
55
     * @return mixed|\stdClass
56
     * @throws \NeedleProject\FileIo\Exception\ContentException
57
     */
58 4
    public function getObject()
59
    {
60 4
        return (object)['content' => $this->content];
61
    }
62
}
63