EvernoteContent   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 64
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A __construct() 0 4 1
A html() 0 6 1
A plain() 0 6 1
A toArray() 0 7 1
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