Conditions | 12 |
Paths | 98 |
Total Lines | 32 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
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 |
||
42 | public function __invoke( |
||
43 | Paginator\Paginator $paginator = null, |
||
44 | $scrollingStyle = null, |
||
45 | $partial = null, |
||
46 | $params = null |
||
47 | ) { |
||
48 | if (is_string($params)) { |
||
49 | $params = (array) $params; |
||
50 | } |
||
51 | |||
52 | if (isset($params['size'])) { |
||
53 | if ($params['size'] != 'sm' && $params['size'] != 'lg') { |
||
54 | throw new \RuntimeException('Size parameter must be either "sm" or "lg"'); |
||
55 | } |
||
56 | } |
||
57 | if ($partial === null && isset($params['type'])) { |
||
58 | if ($params['type'] == 'pager') { |
||
59 | $partial = 'paginator/pager.phtml'; |
||
60 | } |
||
61 | } |
||
62 | if (! isset($params['aligned']) || ! is_bool($params['aligned'])) { |
||
63 | $params['aligned'] = true; |
||
64 | } |
||
65 | if (! isset($params['nextLabel'])) { |
||
66 | $params['nextLabel'] = self::$nextLabel; |
||
67 | } |
||
68 | if (! isset($params['previousLabel'])) { |
||
69 | $params['previousLabel'] = self::$previousLabel; |
||
70 | } |
||
71 | |||
72 | return parent::__invoke($paginator, $scrollingStyle, $partial, $params); |
||
73 | } |
||
74 | } |
||
75 |