Content   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 45
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
A getArray() 0 4 1
A getObject() 0 4 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