| Conditions | 8 |
| Paths | 128 |
| Total Lines | 55 |
| 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 | public function __construct(AddressOptions $params) |
||
| 65 | { |
||
| 66 | $this->informationType = $this->makeType($params->type); |
||
| 67 | |||
| 68 | $this->address = new Address($params->addressLine1); |
||
| 69 | |||
| 70 | if (!empty($params->addressLine2)) { |
||
| 71 | $this->optionalData[] = new OptionalData( |
||
| 72 | $params->addressLine2, |
||
| 73 | OptionalData::OPT_ADDRESS_LINE_2 |
||
| 74 | ); |
||
| 75 | }; |
||
| 76 | |||
| 77 | if (!empty($params->city)) { |
||
| 78 | $this->optionalData[] = new OptionalData( |
||
| 79 | $params->city, |
||
| 80 | OptionalData::OPT_CITY |
||
| 81 | ); |
||
| 82 | }; |
||
| 83 | |||
| 84 | if (!empty($params->country)) { |
||
| 85 | $this->optionalData[] = new OptionalData( |
||
| 86 | $params->country, |
||
| 87 | OptionalData::OPT_COUNTRY |
||
| 88 | ); |
||
| 89 | }; |
||
| 90 | |||
| 91 | if (!empty($params->name)) { |
||
| 92 | $this->optionalData[] = new OptionalData( |
||
| 93 | $params->name, |
||
| 94 | OptionalData::OPT_NAME |
||
| 95 | ); |
||
| 96 | }; |
||
| 97 | |||
| 98 | if (!empty($params->state)) { |
||
| 99 | $this->optionalData[] = new OptionalData( |
||
| 100 | $params->state, |
||
| 101 | OptionalData::OPT_STATE |
||
| 102 | ); |
||
| 103 | }; |
||
| 104 | |||
| 105 | if (!empty($params->zipCode)) { |
||
| 106 | $this->optionalData[] = new OptionalData( |
||
| 107 | $params->zipCode, |
||
| 108 | OptionalData::OPT_ZIP_CODE |
||
| 109 | ); |
||
| 110 | }; |
||
| 111 | |||
| 112 | if (!empty($params->company)) { |
||
| 113 | $this->optionalData[] = new OptionalData( |
||
| 114 | $params->company, |
||
| 115 | OptionalData::OPT_COMPANY |
||
| 116 | ); |
||
| 117 | }; |
||
| 118 | } |
||
| 119 | |||
| 137 |