Conditions | 11 |
Paths | 6 |
Total Lines | 28 |
Code Lines | 15 |
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 |
||
46 | public function matchItem(ItemInterface $item) |
||
47 | { |
||
48 | $admin = $item->getExtra('admin'); |
||
49 | |||
50 | if ($admin instanceof AdminInterface |
||
51 | && $admin->hasRoute('list') && $admin->hasAccess('list') |
||
52 | && $this->request |
||
53 | ) { |
||
54 | $requestCode = $this->request->get('_sonata_admin'); |
||
55 | |||
56 | if ($admin->getCode() === $requestCode) { |
||
57 | return true; |
||
58 | } |
||
59 | |||
60 | foreach ($admin->getChildren() as $child) { |
||
61 | if ($child->getBaseCodeRoute() === $requestCode) { |
||
62 | return true; |
||
63 | } |
||
64 | } |
||
65 | } |
||
66 | |||
67 | $route = $item->getExtra('route'); |
||
68 | if ($route && $this->request && $route == $this->request->get('_route')) { |
||
69 | return true; |
||
70 | } |
||
71 | |||
72 | return null; |
||
73 | } |
||
74 | } |
||
75 |