Conditions | 13 |
Paths | 36 |
Total Lines | 39 |
Code Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
15 | public function setRecipient($Recipient) |
||
16 | { |
||
17 | if (isset($Recipient['RecipientsPhone'])) { |
||
18 | $this->methodProperties['RecipientsPhone'] = $Recipient['RecipientsPhone']; |
||
1 ignored issue
–
show
|
|||
19 | } |
||
20 | |||
21 | //указываем идентификаторами проверяем и вставляем |
||
22 | if (isset($Recipient['Recipient']) && |
||
23 | isset($Recipient['ContactRecipient']) && |
||
24 | isset($Recipient['CityRecipient']) && |
||
25 | isset($Recipient['RecipientAddress']) |
||
26 | ) { |
||
27 | $this->methodProperties['Recipient'] = $Recipient['Recipient']; |
||
28 | $this->methodProperties['ContactRecipient'] = $Recipient['ContactRecipient']; |
||
29 | $this->methodProperties['CityRecipient'] = $Recipient['CityRecipient']; |
||
30 | $this->methodProperties['RecipientAddress'] = $Recipient['RecipientAddress']; |
||
31 | |||
32 | return $this; |
||
33 | } |
||
34 | |||
35 | //указываем строками проверяем и вставляем |
||
36 | if (isset($Recipient['RecipientName']) && //имя получателя |
||
37 | isset($Recipient['RecipientCityName']) && //город |
||
38 | isset($Recipient['RecipientAddressName']) //отделение или улица |
||
39 | ) { |
||
40 | //создаем новый адрес |
||
41 | $this->methodProperties['NewAddress'] = 1; |
||
42 | |||
43 | $this->methodProperties['RecipientName'] = $Recipient['RecipientName']; |
||
44 | $this->methodProperties['RecipientCityName'] = $Recipient['RecipientCityName']; |
||
45 | $this->methodProperties['RecipientAddressName'] = $Recipient['RecipientAddressName']; |
||
46 | |||
47 | $this->methodProperties['RecipientArea'] = isset($Recipient['RecipientArea']) ? $Recipient['RecipientArea'] : ''; |
||
48 | $this->methodProperties['RecipientAreaRegions'] = isset($Recipient['RecipientAreaRegions']) ? $Recipient['RecipientAreaRegions'] : ''; |
||
49 | $this->methodProperties['RecipientHouse'] = isset($Recipient['RecipientHouse']) ? $Recipient['RecipientHouse'] : ''; |
||
50 | $this->methodProperties['RecipientFlat'] = isset($Recipient['RecipientFlat']) ? $Recipient['RecipientFlat'] : ''; |
||
51 | } |
||
52 | |||
53 | return $this; |
||
54 | } |
||
81 |