| Conditions | 11 |
| Paths | 28 |
| Total Lines | 57 |
| Code Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 74 | public function load($file_name, $fatal = true, $fix_calendar_arrays = false) |
||
| 75 | { |
||
| 76 | global $db_show_debug, $txt; |
||
| 77 | |||
| 78 | $file_names = explode('+', $file_name); |
||
| 79 | |||
| 80 | // For each file open it up and write it out! |
||
| 81 | foreach ($file_names as $file) |
||
| 82 | { |
||
| 83 | $file = ucfirst($file); |
||
| 84 | if (isset($this->loaded[$file]) || in_array($file, Editor::IGNORE_FILES)) |
||
| 85 | { |
||
| 86 | continue; |
||
| 87 | } |
||
| 88 | |||
| 89 | $found = false; |
||
|
|
|||
| 90 | $found_fallback = false; |
||
| 91 | if ($this->load_fallback) |
||
| 92 | { |
||
| 93 | $found_fallback = $this->loadFile($file, 'English'); |
||
| 94 | } |
||
| 95 | $found = $this->loadFile($file, $this->language); |
||
| 96 | |||
| 97 | $this->loaded[$file] = true; |
||
| 98 | |||
| 99 | // Keep track of what we're up to, soldier. |
||
| 100 | if ($found && $db_show_debug === true) |
||
| 101 | { |
||
| 102 | Debug::instance()->add( |
||
| 103 | 'language_files', |
||
| 104 | $file . '.' . $this->language . |
||
| 105 | ' (' . str_replace(BOARDDIR, '', $this->path) . ')' |
||
| 106 | ); |
||
| 107 | } |
||
| 108 | |||
| 109 | // That couldn't be found! Log the error, but *try* to continue normally. |
||
| 110 | if (!$found && $fatal) |
||
| 111 | { |
||
| 112 | Errors::instance()->log_error( |
||
| 113 | sprintf( |
||
| 114 | $txt['theme_language_error'], |
||
| 115 | $file . '.' . $this->language, |
||
| 116 | 'template' |
||
| 117 | ) |
||
| 118 | ); |
||
| 119 | // If we do have a fallback it may not be necessary to break out. |
||
| 120 | if ($found_fallback === false) |
||
| 121 | { |
||
| 122 | break; |
||
| 123 | } |
||
| 124 | } |
||
| 125 | } |
||
| 126 | $this->loadFromDb($file_names); |
||
| 127 | |||
| 128 | if ($fix_calendar_arrays) |
||
| 129 | { |
||
| 130 | $this->fix_calendar_text(); |
||
| 131 | } |
||
| 242 | } |