EvernoteContent::html()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NotificationChannels\Evernote;
4
5
class EvernoteContent
6
{
7
    const TYPE_HTML = 'html';
8
    const TYPE_PLAIN = 'plain';
9
10
    /** @var string */
11
    protected $content;
12
13
    /** @var array */
14
    protected $type = self::TYPE_PLAIN;
15
16
    /**
17
     * @param string $content
18
     *
19
     * @return static
20
     */
21 4
    public static function create($content)
22
    {
23 4
        return new static($content);
24
    }
25
26
    /**
27
     * @param string $content
28
     */
29 8
    public function __construct($content)
30
    {
31 8
        $this->content = $content;
32 8
    }
33
34
    /**
35
     * Set the content type to HTML.
36
     *
37
     * @return $this
38
     */
39 1
    public function html()
40
    {
41 1
        $this->type = self::TYPE_HTML;
0 ignored issues
show
Documentation Bug introduced by
It seems like self::TYPE_HTML of type string is incompatible with the declared type array of property $type.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
43 1
        return $this;
44
    }
45
46
    /**
47
     * Set the content type to plaintext.
48
     *
49
     * @return $this
50
     */
51 1
    public function plain()
52
    {
53 1
        $this->type = self::TYPE_PLAIN;
0 ignored issues
show
Documentation Bug introduced by
It seems like self::TYPE_PLAIN of type string is incompatible with the declared type array of property $type.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
54
55 1
        return $this;
56
    }
57
58
    /**
59
     * @return array
60
     */
61 8
    public function toArray()
62
    {
63
        return [
64 8
            'content' => $this->content,
65 8
            'type' => $this->type,
66 8
        ];
67
    }
68
}
69