| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 41 |
| 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 |
||
| 39 | public function buildDataSet(Lang $lang) |
||
| 40 | { |
||
| 41 | $contactInfoType = "CASE ".DealerContactInfoTableMap::CONTACT_TYPE. |
||
| 42 | " WHEN 0 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_EMAIL."'". |
||
| 43 | " WHEN 1 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_TEL."'". |
||
| 44 | " WHEN 2 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_FAX."'". |
||
| 45 | " WHEN 3 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_URL."'". |
||
| 46 | " WHEN 4 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_FACEBOOK."'". |
||
| 47 | " WHEN 5 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_TWITTER."'". |
||
| 48 | " WHEN 6 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_PINTEREST."'". |
||
| 49 | " WHEN 7 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_GOOGLE."'". |
||
| 50 | " WHEN 8 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_YOUTUBE."'". |
||
| 51 | " WHEN 9 THEN '".DealerContactInfoTableMap::CONTACT_TYPE_INSTAGRAM."'". |
||
| 52 | " ELSE '?'". |
||
| 53 | " END"; |
||
| 54 | |||
| 55 | |||
| 56 | $dealer = DealerQuery::create() |
||
| 57 | ->useDealerI18nQuery() |
||
| 58 | ->addAsColumn("dealer_TITLE", DealerI18nTableMap::TITLE) |
||
| 59 | ->endUse() |
||
| 60 | ->useDealerContactQuery() |
||
| 61 | ->addAsColumn("contact_DEFAULT", DealerContactTableMap::IS_DEFAULT) |
||
| 62 | ->useDealerContactI18nQuery() |
||
| 63 | ->addAsColumn("contact_LABEL", DealerContactI18nTableMap::LABEL) |
||
| 64 | ->endUse() |
||
| 65 | ->useDealerContactInfoQuery() |
||
| 66 | //->addAsColumn("contact_TYPE", DealerContactInfoTableMap::CONTACT_TYPE) |
||
| 67 | ->addAsColumn("contact_TYPE_NAME", $contactInfoType) |
||
| 68 | ->useDealerContactInfoI18nQuery() |
||
| 69 | ->addAsColumn("contact_VALUE", DealerContactInfoI18nTableMap::VALUE) |
||
| 70 | ->endUse() |
||
| 71 | ->endUse() |
||
| 72 | ->endUse() |
||
| 73 | |||
| 74 | |||
| 75 | |||
| 76 | ->select([ |
||
| 77 | DealerTableMap::ID, |
||
| 78 | 'dealer_TITLE', |
||
| 79 | 'contact_LABEL', |
||
| 80 | 'contact_DEFAULT', |
||
| 81 | 'contact_TYPE_NAME', |
||
| 82 | 'contact_VALUE' |
||
| 83 | ]) |
||
| 84 | ->orderById() |
||
| 85 | ->find() |
||
| 86 | ->toArray() |
||
| 87 | ; |
||
| 88 | |||
| 89 | return $dealer; |
||
| 90 | } |
||
| 91 | |||
| 139 |