| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 38 |
| 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 |
||
| 29 | public function buildOrderMenu(FactoryInterface $factory) |
||
| 30 | { |
||
| 31 | $menu = $factory->createItem('root'); |
||
| 32 | $menu->setChildrenAttribute('class', 'nav navbar-nav'); |
||
| 33 | |||
| 34 | $menu->addChild('order', array('label' => 'menu.order')) |
||
| 35 | ->setExtra('translation_domain', 'messages') |
||
| 36 | ->setAttribute('dropdown', true) |
||
| 37 | ->setAttribute('icon', 'fa fa-shopping-cart'); |
||
| 38 | |||
| 39 | $menu['order']->addChild('orders', ['label' => 'title_short', 'route' => 'orders', ]) |
||
| 40 | ->setExtra('translation_domain', 'gs_orders') |
||
| 41 | ->setAttribute('icon', 'fa fa-shopping-cart'); |
||
| 42 | |||
| 43 | $menu['order']->addChild('deliveries', ['label' => 'title_short', 'route' => 'deliveries', ]) |
||
| 44 | ->setExtra('translation_domain', 'gs_deliveries') |
||
| 45 | ->setAttribute('icon', 'fa fa-truck'); |
||
| 46 | |||
| 47 | $menu['order']->addChild('invoices', ['label' => 'title_short', 'route' => 'invoices', ]) |
||
| 48 | ->setExtra('translation_domain', 'gs_invoices') |
||
| 49 | ->setAttribute('icon', 'fa fa-calculator'); |
||
| 50 | |||
| 51 | return $menu; |
||
| 52 | } |
||
| 53 | |||
| 54 | public function buildStockMenu(FactoryInterface $factory) |
||
| 55 | { |
||
| 56 | $menu = $factory->createItem('root'); |
||
| 57 | $menu->setChildrenAttribute('class', 'nav navbar-nav'); |
||
| 58 | |||
| 59 | $menu->addChild('stock', array('label' => 'menu.stock')) |
||
| 60 | ->setExtra('translation_domain', 'messages') |
||
| 61 | ->setAttribute('dropdown', true) |
||
| 62 | ->setAttribute('icon', 'fa fa-dashboard'); |
||
| 63 | |||
| 64 | $menu['stock']->addChild('inventory', ['label' => 'title_short', 'route' => 'inventory', ]) |
||
| 65 | ->setExtra('translation_domain', 'gs_inventories') |
||
| 66 | ->setAttribute('icon', 'fa fa-tasks'); |
||
| 67 | |||
| 68 | $menu['stock']->addChild('articles', ['label' => 'menu.articles', 'route' => 'article', ]) |
||
| 69 | ->setExtra('translation_domain', 'gs_articles') |
||
| 70 | ->setAttribute('icon', 'fa fa-list'); |
||
| 71 | |||
| 72 | return $menu; |
||
| 73 | } |
||
| 74 | |||
| 75 | public function buildConfigMenu(FactoryInterface $factory) |
||
| 76 | { |
||
| 77 | $menu = $factory->createItem('root'); |
||
| 78 | $menu->setChildrenAttribute('class', 'nav navbar-nav'); |
||
| 79 | |||
| 80 | $menu->addChild('config', array('label' => 'menu.configuration')) |
||
| 81 | ->setExtra('translation_domain', 'messages') |
||
| 82 | ->setAttribute('dropdown', true) |
||
| 83 | ->setAttribute('icon', 'fa fa-cog'); |
||
| 169 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.