Completed
Pull Request — develop (#32)
by Michael
06:53
created

Reply   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 4 1
A __construct() 0 8 3
1
<?php
2
3
namespace Crummy\Phlack\WebHook\Reply;
4
5
use Crummy\Phlack\Common\Hash;
6
7
class Reply extends Hash
8
{
9
    protected $required = ['text'];
10
    protected $defaults = ['text' => ''];
11
12
    /**
13
     * @param mixed $data
14
     */
15 17
    public function __construct($data = [])
16
    {
17 17
        if (!is_array($data) && !empty($data)) {
18 1
            $data = ['text' => $data];
19
        }
20
21 17
        parent::__construct($data);
22 17
    }
23
24
    /**
25
     * Returns only the text value.
26
     *
27
     * @return array
28
     */
29 4
    public function toArray()
30
    {
31 4
        return ['text' => $this->data['text']];
32
    }
33
}
34