Conditions | 10 |
Paths | 8 |
Total Lines | 28 |
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 |
||
52 | public static function getCaller() |
||
53 | { |
||
54 | $backtraces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); |
||
55 | $nextIsCaller = false; |
||
56 | $caller = null; |
||
57 | foreach ($backtraces as $backtrace) { |
||
58 | if ( |
||
59 | isset($backtrace['file']) |
||
60 | && strpos($backtrace['file'], static::$callerRemoveFile) !== false |
||
61 | ) { |
||
62 | $nextIsCaller = true; |
||
63 | } elseif ( |
||
64 | $nextIsCaller |
||
65 | && ( |
||
66 | (isset($backtrace['file']) && strpos($backtrace['file'], static::$callerRemoveFile) === false) |
||
67 | || isset($backtrace['file']) === false |
||
68 | ) |
||
69 | ) { |
||
70 | $caller = $backtrace; |
||
71 | break; |
||
72 | } |
||
73 | } |
||
74 | if ($nextIsCaller === false && count($backtraces) > 0) { |
||
75 | $caller = $backtraces[0]; |
||
76 | } |
||
77 | |||
78 | return $caller; |
||
79 | } |
||
80 | |||
114 |