| Conditions | 10 |
| Paths | 9 |
| Total Lines | 36 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 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 kcfinder\integration; |
||
| 20 | static function getLaravelPath() { |
||
| 21 | |||
| 22 | //absolute path method |
||
| 23 | if (!empty($_SERVER['SCRIPT_FILENAME'])) { |
||
| 24 | $laravelPath = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])))))))); |
||
| 25 | if (!file_exists($laravelPath . self::$bootstrapAutoload)) { |
||
| 26 | $laravelPath = dirname(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])))); |
||
| 27 | $depth = 3; |
||
| 28 | do { |
||
| 29 | $laravelPath = dirname($laravelPath); |
||
| 30 | $depth++; |
||
| 31 | $autoloadFound = file_exists($laravelPath . self::$bootstrapAutoload); |
||
| 32 | } while (!$autoloadFound && $depth < 10); |
||
| 33 | } |
||
| 34 | else { |
||
| 35 | $autoloadFound = true; |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | //relative path method |
||
| 40 | if (!isset($autoloadFound) || !$autoloadFound) { |
||
| 41 | $laravelPath = '../../../../../../..'; |
||
| 42 | if (!file_exists($laravelPath . self::$bootstrapAutoload)) { |
||
| 43 | $laravelPath = '../../..'; |
||
| 44 | $depth = 3; |
||
| 45 | do { |
||
| 46 | $laravelPath .= '/..'; |
||
| 47 | $depth++; |
||
| 48 | } while (!($autoloadFound = file_exists($laravelPath . self::$bootstrapAutoload)) && $depth < 10); |
||
|
|
|||
| 49 | } |
||
| 50 | else { |
||
| 51 | $autoloadFound = true; |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | return $laravelPath; |
||
| 56 | } |
||
| 137 |