Comment   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 46
ccs 13
cts 13
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addAttachment() 0 4 1
A setMessage() 0 4 1
A toArray() 0 12 2
1
<?php
2
3
namespace Manavo\DoneDone;
4
5
class Comment
6
{
7
8
    /**
9
     * @var string
10
     */
11
    private $message = null;
12
13
    /**
14
     * @var array
15
     */
16
    private $attachments = [];
17
18
    /**
19
     * @param string $attachment
20
     */
21 3
    public function addAttachment($attachment)
22
    {
23 3
        $this->attachments[] = $attachment;
24 3
    }
25
26
    /**
27
     * @param string $message
28
     */
29 3
    public function setMessage($message)
30
    {
31 3
        $this->message = $message;
32 3
    }
33
34
    /**
35
     * @return array
36
     */
37 9
    public function toArray()
38
    {
39
        $data = [
40 9
            'comment' => $this->message,
41 9
        ];
42
43 9
        foreach ($this->attachments as $index => $attachment) {
44 3
            $data['attachment-' . $index] = fopen($attachment, 'r');
45 9
        }
46
47 9
        return $data;
48
    }
49
50
}
51