| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 36 | public function buildDataSet(Lang $lang) |
||
| 37 | { |
||
| 38 | $locale = $lang->getLocale(); |
||
| 39 | |||
| 40 | $dealer = DealerQuery::create() |
||
| 41 | ->useCountryQuery() |
||
| 42 | ->useCountryI18nQuery() |
||
| 43 | ->addAsColumn("address_COUNTRY", CountryI18nTableMap::TITLE) |
||
| 44 | ->endUse() |
||
| 45 | ->endUse() |
||
| 46 | ->useDealerI18nQuery() |
||
| 47 | ->addAsColumn("dealer_TITLE", DealerI18nTableMap::TITLE) |
||
| 48 | ->addAsColumn("dealer_DESCRIPTION", DealerI18nTableMap::DESCRIPTION) |
||
| 49 | ->addAsColumn("dealer_ACCESS", DealerI18nTableMap::ACCESS) |
||
| 50 | ->endUse() |
||
| 51 | ->select([ |
||
| 52 | DealerTableMap::ID, |
||
| 53 | //DealerTableMap::VERSION, |
||
| 54 | DealerTableMap::VISIBLE, |
||
| 55 | 'dealer_TITLE', |
||
| 56 | 'dealer_DESCRIPTION', |
||
| 57 | 'dealer_ACCESS', |
||
| 58 | DealerTableMap::ADDRESS1, |
||
| 59 | DealerTableMap::ADDRESS2, |
||
| 60 | DealerTableMap::ADDRESS3, |
||
| 61 | DealerTableMap::ZIPCODE, |
||
| 62 | DealerTableMap::CITY, |
||
| 63 | DealerTableMap::COUNTRY_ID, |
||
| 64 | 'address_COUNTRY', |
||
| 65 | DealerTableMap::LATITUDE, |
||
| 66 | DealerTableMap::LONGITUDE |
||
| 67 | ]) |
||
| 68 | ->orderById() |
||
| 69 | ; |
||
| 70 | |||
| 71 | I18n::addI18nCondition( |
||
| 72 | $dealer, |
||
| 73 | CountryI18nTableMap::TABLE_NAME, |
||
| 74 | CountryTableMap::ID, |
||
| 75 | CountryI18nTableMap::ID, |
||
| 76 | CountryI18nTableMap::LOCALE, |
||
| 77 | $locale |
||
| 78 | ); |
||
| 79 | |||
| 80 | $dealer |
||
| 81 | ->find() |
||
| 82 | ->toArray() |
||
| 83 | ; |
||
| 84 | |||
| 85 | return $dealer; |
||
| 86 | } |
||
| 87 | |||
| 153 |