Completed
Push — master ( 168b8f...f2b799 )
by Tobias
02:41
created

AutomaticReminder::toArray()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 0
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Model\Invoice;
6
7
use Billogram\Model\CreatableFromArray;
8
9
/**
10
 * @author Ibrahim Hizeoui <[email protected]>
11
 */
12
class AutomaticReminder implements CreatableFromArray
13
{
14
    /**
15
     * @var int
16
     */
17
    private $delayDays;
18
19
    /**
20
     * @var string
21
     */
22
    private $message;
23
24 1
    public function toArray()
25
    {
26 1
        $data = [];
27 1
        if ($this->delayDays !== null) {
28 1
            $data['delay_days'] = $this->delayDays;
29
        }
30 1
        if ($this->message !== null) {
31 1
            $data['message'] = $this->message;
32
        }
33
34 1
        return $data;
35
    }
36
37
    /**
38
     * Create an API response object from the HTTP response from the API server.
39
     *
40
     * @param array $data
41
     *
42
     * @return self
43
     */
44 2
    public static function createFromArray(array $data)
45
    {
46 2
        $automaticReminder = new self();
47 2
        $automaticReminder->delayDays = $data['delay_days'] ?? null;
48 2
        $automaticReminder->message = $data['message'] ?? null;
49
50 2
        return $automaticReminder;
51
    }
52
}
53