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

Reply::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 3
eloc 4
nc 2
nop 1
crap 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