Content::getObject()   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

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($content)
31
    {
32 20
        $this->content = $content;
33 20
    }
34
35
    /**
36
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be null|string?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
37
     */
38 26
    public function get()
39
    {
40 26
        return $this->content;
41
    }
42
43
    /**
44
     * Return the content as an array
45
     *
46
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<null|string>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
47
     * @throws \NeedleProject\FileIo\Exception\ContentException
48
     */
49 4
    public function getArray()
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