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

src/Model/Invoice/AutomaticCollection.php (1 issue)

duplicate/similar classes.

Duplication Informational

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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