Conditions | 10 |
Paths | 512 |
Total Lines | 43 |
Code Lines | 21 |
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 namespace SimpleUPS; |
||
118 | public function toXml(\DomDocument $dom) |
||
119 | { |
||
120 | $address = $dom->createElement('Address'); |
||
121 | |||
122 | if ($this->getAddressee() != null) //no UPS api uses this |
||
123 | { |
||
124 | $address->appendChild($dom->createElement('Addressee', $this->getAddressee())); |
||
125 | } |
||
126 | |||
127 | if ($this->getStreet() != null) { |
||
128 | $address->appendChild($dom->createElement('AddressLine1', $this->getStreet())); |
||
129 | } |
||
130 | |||
131 | if ($this->getAddressLine2() != null) { |
||
132 | $address->appendChild($dom->createElement('AddressLine2', $this->getAddressLine2())); |
||
133 | } |
||
134 | |||
135 | if ($this->getAddressLine3() != null) { |
||
136 | $address->appendChild($dom->createElement('AddressLine3', $this->getAddressLine3())); |
||
137 | } |
||
138 | |||
139 | if ($this->getCity() != null) { |
||
140 | $address->appendChild($dom->createElement('City', $this->getCity())); |
||
141 | } |
||
142 | |||
143 | if ($this->getStateProvinceCode() != null) { |
||
144 | $address->appendChild($dom->createElement('StateProvinceCode', $this->getStateProvinceCode())); |
||
145 | } |
||
146 | |||
147 | if ($this->getPostalCode() != null) { |
||
148 | $address->appendChild($dom->createElement('PostalCode', $this->getPostalCode())); |
||
149 | } |
||
150 | |||
151 | if ($this->getCountryCode() != null) { |
||
152 | $address->appendChild($dom->createElement('CountryCode', $this->getCountryCode())); |
||
153 | } |
||
154 | |||
155 | if ($this->isResidential()) { |
||
156 | $address->appendChild($dom->createElement('ResidentialAddressIndicator')); |
||
157 | } |
||
158 | |||
159 | return $address; |
||
160 | } |
||
161 | |||
207 | } |