Conditions | 11 |
Paths | 11 |
Total Lines | 47 |
Code Lines | 22 |
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 namespace Understand\UnderstandLaravel5; |
||
114 | protected function stackTraceArgsToArray(array $trace) |
||
115 | { |
||
116 | $params = []; |
||
117 | |||
118 | if (! isset($trace['args'])) |
||
119 | { |
||
120 | return $params; |
||
121 | } |
||
122 | |||
123 | foreach ($trace['args'] as $arg) |
||
124 | { |
||
125 | if (is_array($arg)) |
||
126 | { |
||
127 | $params[] = 'array(' . count($arg) . ')'; |
||
128 | } |
||
129 | else if (is_object($arg)) |
||
130 | { |
||
131 | $params[] = get_class($arg); |
||
132 | } |
||
133 | else if (is_string($arg)) |
||
134 | { |
||
135 | $params[] = 'string(' . $arg . ')'; |
||
136 | } |
||
137 | else if (is_int($arg)) |
||
138 | { |
||
139 | $params[] = 'int(' . $arg . ')'; |
||
140 | } |
||
141 | else if (is_float($arg)) |
||
142 | { |
||
143 | $params[] = 'float(' . $arg . ')'; |
||
144 | } |
||
145 | else if (is_bool($arg)) |
||
146 | { |
||
147 | $params[] = 'bool(' . ($arg ? 'true' : 'false') . ')'; |
||
148 | } |
||
149 | else if ($arg instanceof \__PHP_Incomplete_Class) |
||
150 | { |
||
151 | $params[] = 'object(__PHP_Incomplete_Class)'; |
||
152 | } |
||
153 | else |
||
154 | { |
||
155 | $params[] = gettype($arg); |
||
156 | } |
||
157 | } |
||
158 | |||
159 | return $params; |
||
160 | } |
||
161 | |||
163 |