Completed
Push — master ( c13142...c0435c )
by Tobias
02:34
created

AutomaticCollection::toArray()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 12
loc 12
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 4
nop 0
crap 12
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 View Code Duplication
class AutomaticCollection implements CreatableFromArray
0 ignored issues
show
Duplication introduced by Ibrahimhizeoui
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var int
16
     */
17
    private $delayDays;
18
19
    /**
20
     * @var int
21
     */
22
    private $amount;
23
24
    public function toArray()
25
    {
26
        $data = [];
27
        if ($this->delayDays !== null) {
28
            $data['delay_days'] = $this->delayDays;
29
        }
30
        if ($this->amount !== null) {
31
            $data['message'] = $this->amount;
32
        }
33
34
        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 3
    public static function createFromArray(array $data)
45
    {
46 3
        $automaticReminder = new self();
47 3
        $automaticReminder->delayDays = $data['delay_days'];
48 3
        $automaticReminder->amount = $data['amount'];
49
50 3
        return $automaticReminder;
51
    }
52
}
53