TrelloMessage   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 129
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 0
loc 129
ccs 30
cts 30
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 4 1
A __construct() 0 4 1
A name() 0 6 1
A description() 0 6 1
A position() 0 6 1
A top() 0 6 1
A bottom() 0 6 1
A due() 0 10 2
A toArray() 0 9 1
1
<?php
2
3
namespace NotificationChannels\Trello;
4
5
use DateTime;
6
7
class TrelloMessage
8
{
9
    /** @var string */
10
    protected $name;
11
12
    /** @var string */
13
    protected $description;
14
15
    /** @var string|int */
16
    protected $position;
17
18
    /** @var string|null */
19
    protected $due;
20
21
    /**
22
     * @param string $name
23
     *
24
     * @return static
25
     */
26 1
    public static function create($name = '')
27
    {
28 1
        return new static($name);
29
    }
30
31
    /**
32
     * @param string $name
33
     */
34 11
    public function __construct($name = '')
35
    {
36 11
        $this->name = $name;
37 11
    }
38
39
    /**
40
     * Set the card name.
41
     *
42
     * @param $name
43
     *
44
     * @return $this
45
     */
46 1
    public function name($name)
47
    {
48 1
        $this->name = $name;
49
50 1
        return $this;
51
    }
52
53
    /**
54
     * Set the card description.
55
     *
56
     * @param $description
57
     *
58
     * @return $this
59
     */
60 3
    public function description($description)
61
    {
62 3
        $this->description = $description;
63
64 3
        return $this;
65
    }
66
67
    /**
68
     * Set the card position.
69
     *
70
     * @param string|int $position
71
     *
72
     * @return $this
73
     */
74 1
    public function position($position)
75
    {
76 1
        $this->position = $position;
77
78 1
        return $this;
79
    }
80
81
    /**
82
     * Set the card position to 'top'.
83
     *
84
     * @return $this
85
     */
86 3
    public function top()
87
    {
88 3
        $this->position = 'top';
89
90 3
        return $this;
91
    }
92
93
    /**
94
     * Set the card position to 'bottom'.
95
     *
96
     * @return $this
97
     */
98 1
    public function bottom()
99
    {
100 1
        $this->position = 'bottom';
101
102 1
        return $this;
103
    }
104
105
    /**
106
     * Set the card position due date.
107
     *
108
     * @param string|DateTime $due
109
     *
110
     * @return $this
111
     */
112 2
    public function due($due)
113
    {
114 2
        if (! $due instanceof DateTime) {
115 1
            $due = new DateTime($due);
116
        }
117
118 2
        $this->due = $due->format(DateTime::ATOM);
119
120 2
        return $this;
121
    }
122
123
    /**
124
     * @return array
125
     */
126 11
    public function toArray()
127
    {
128
        return [
129 11
            'name' => $this->name,
130 11
            'desc' => $this->description,
131 11
            'pos' => $this->position,
132 11
            'due' => $this->due,
133
        ];
134
    }
135
}
136