| Conditions | 10 |
| Paths | 512 |
| Total Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 64 | protected function loadAddress($opt) |
||
| 65 | { |
||
| 66 | if (!empty($opt->company)) { |
||
| 67 | $this->address[] = new Address( |
||
| 68 | Address::OPTION_COMPANY, |
||
| 69 | $opt->company |
||
| 70 | ); |
||
| 71 | } |
||
| 72 | if (!empty($opt->name)) { |
||
| 73 | $this->address[] = new Address( |
||
| 74 | Address::OPTION_NAME, |
||
| 75 | $opt->name |
||
| 76 | ); |
||
| 77 | } |
||
| 78 | if (!empty($opt->addressLine1)) { |
||
| 79 | $this->address[] = new Address( |
||
| 80 | Address::OPTION_ADDRESS_LINE_1, |
||
| 81 | $opt->addressLine1 |
||
| 82 | ); |
||
| 83 | } |
||
| 84 | if (!empty($opt->addressLine2)) { |
||
| 85 | $this->address[] = new Address( |
||
| 86 | Address::OPTION_ADDRESS_LINE_2, |
||
| 87 | $opt->addressLine2 |
||
| 88 | ); |
||
| 89 | } |
||
| 90 | if (!empty($opt->city)) { |
||
| 91 | $this->address[] = new Address( |
||
| 92 | Address::OPTION_CITY, |
||
| 93 | $opt->city |
||
| 94 | ); |
||
| 95 | } |
||
| 96 | if (!empty($opt->country)) { |
||
| 97 | $this->address[] = new Address( |
||
| 98 | Address::OPTION_COUNTRY, |
||
| 99 | $opt->country |
||
| 100 | ); |
||
| 101 | } |
||
| 102 | if (!empty($opt->poBox)) { |
||
| 103 | $this->address[] = new Address( |
||
| 104 | Address::OPTION_PO_BOX, |
||
| 105 | $opt->poBox |
||
| 106 | ); |
||
| 107 | } |
||
| 108 | if (!empty($opt->postalCode)) { |
||
| 109 | $this->address[] = new Address( |
||
| 110 | Address::OPTION_POSTAL_CODE, |
||
| 111 | $opt->postalCode |
||
| 112 | ); |
||
| 113 | } |
||
| 114 | if (!empty($opt->state)) { |
||
| 115 | $this->address[] = new Address( |
||
| 116 | Address::OPTION_STATE, |
||
| 117 | $opt->state |
||
| 118 | ); |
||
| 119 | } |
||
| 120 | } |
||
| 121 | } |
||
| 122 |