ContactPatchApiModel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 141
Duplicated Lines 11.35 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 16
loc 141
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 16 16 3
A getAvailableProperties() 0 24 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Fousky\Component\iDoklad\Model\Contacts;
4
5
use Fousky\Component\iDoklad\Model\BankAccounts\BankAccountPostApiModel;
6
use Fousky\Component\iDoklad\Model\iDokladAbstractModel;
7
use Symfony\Component\Validator\Constraints as Assert;
8
9
/**
10
 * @method null|string getCity()
11
 * @method null|string getCompanyName()
12
 * @method null|int getCountryId()
13
 * @method null|BankAccountPostApiModel getDefaultBankAccount()
14
 * @method null|float getDiscountPercentage()
15
 * @method null|string getEmail()
16
 * @method null|string getFax()
17
 * @method null|string getFirstname()
18
 * @method null|string getIdentificationNumber()
19
 * @method null|bool getIsSendReminder()
20
 * @method null|string getMobile()
21
 * @method null|string getPhone()
22
 * @method null|string getPostalCode()
23
 * @method null|string getStreet()
24
 * @method null|string getSurname()
25
 * @method null|string getTitle()
26
 * @method null|string getVatIdentificationNumber()
27
 * @method null|string getVatIdentificationNumberSk()
28
 * @method null|string getWww()
29
 *
30
 * @author Lukáš Brzák <[email protected]>
31
 */
32
class ContactPatchApiModel extends iDokladAbstractModel
33
{
34
    /**
35
     * @Assert\Length(min="0", max="50")
36
     */
37
    public $City;
38
39
    /**
40
     * @Assert\Length(min="0", max="200")
41
     */
42
    public $CompanyName;
43
44
    public $CountryId;
45
46
    /**
47
     * @var null|BankAccountPostApiModel
48
     *
49
     * @Assert\Valid()
50
     */
51
    public $DefaultBankAccount;
52
53
    public $DiscountPercentage;
54
55
    /**
56
     * @Assert\Length(min="0", max="50")
57
     */
58
    public $Email;
59
60
    /**
61
     * @Assert\Length(min="0", max="20")
62
     */
63
    public $Fax;
64
65
    /**
66
     * @Assert\Length(min="0", max="50")
67
     */
68
    public $Firstname;
69
70
    /**
71
     * @Assert\Length(min="0", max="20")
72
     */
73
    public $IdentificationNumber;
74
75
    public $IsSendReminder;
76
77
    /**
78
     * @Assert\Length(min="0", max="20")
79
     */
80
    public $Mobile;
81
82
    /**
83
     * @Assert\Length(min="0", max="20")
84
     */
85
    public $Phone;
86
87
    /**
88
     * @Assert\Length(min="0", max="11")
89
     */
90
    public $PostalCode;
91
92
    /**
93
     * @Assert\Length(min="0", max="100")
94
     */
95
    public $Street;
96
97
    /**
98
     * @Assert\Length(min="0", max="50")
99
     */
100
    public $Surname;
101
102
    /**
103
     * @Assert\Length(min="0", max="50")
104
     */
105
    public $Title;
106
107
    /**
108
     * @Assert\Length(min="0", max="20")
109
     */
110
    public $VatIdentificationNumber;
111
112
    /**
113
     * @Assert\Length(min="0", max="20")
114
     */
115
    public $VatIdentificationNumberSk;
116
117
    /**
118
     * @Assert\Length(min="0", max="50")
119
     */
120
    public $Www;
121
122
    /**
123
     * @param BankAccountPostApiModel|null $bankAccount
124
     * @param array                        $properties
125
     *
126
     * @throws \InvalidArgumentException
127
     */
128 View Code Duplication
    public function __construct(BankAccountPostApiModel $bankAccount = null, array $properties = [])
0 ignored issues
show
Duplication introduced by
This method 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...
129
    {
130
        $this->DefaultBankAccount = $bankAccount;
131
132
        foreach ($properties as $key => $value) {
133
            if (!property_exists($this, $key)) {
134
                throw new \InvalidArgumentException(sprintf(
135
                    'Property %s of class %s does not exists.',
136
                    $key,
137
                    __CLASS__
138
                ));
139
            }
140
141
            $this->{$key} = $value;
142
        }
143
    }
144
145
    /**
146
     * @return array
147
     */
148
    public function getAvailableProperties(): array
149
    {
150
        return [
151
            'City',
152
            'CompanyName',
153
            'CountryId',
154
            'DefaultBankAccount',
155
            'DiscountPercentage',
156
            'Email',
157
            'Fax',
158
            'Firstname',
159
            'IdentificationNumber',
160
            'IsSendReminder',
161
            'Mobile',
162
            'Phone',
163
            'PostalCode',
164
            'Street',
165
            'Surname',
166
            'Title',
167
            'VatIdentificationNumber',
168
            'VatIdentificationNumberSk',
169
            'Www',
170
        ];
171
    }
172
}
173