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