| Conditions | 12 |
| Paths | 28 |
| Total Lines | 55 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 8 | ||
| Bugs | 2 | Features | 1 |
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 |
||
| 112 | { |
||
| 113 | return $this->l('DATETIME_CALENDAR_DAY_' . Dato::format($date_string, 'N')); |
||
| 114 | } |
||
| 115 | |||
| 116 | public function seconds($seconds) |
||
| 117 | { |
||
| 118 | $hours = floor($seconds / 3600); |
||
| 119 | $mins = floor(($seconds - $hours * 3600) / 60); |
||
| 120 | $secs = floor($seconds % 60); |
||
| 121 | |||
| 122 | $hours_format = '%dh %dm %ds'; |
||
| 123 | return sprintf($hours_format, $hours, $mins, $secs); |
||
| 124 | } |
||
| 125 | |||
| 126 | public function init() { |
||
| 127 | if ($this->isInitialized()) { |
||
| 128 | throw new \BadMethodCallException('This object from class ' . __CLASS__ . ' is already initialized. It is not possible to init one object twice!'); |
||
| 129 | } |
||
| 130 | |||
| 131 | $this->isInitialized = true; |
||
| 132 | |||
| 133 | $this->userLangs = $this->getUserLangs(); |
||
| 134 | |||
| 135 | // search for language file |
||
| 136 | $this->appliedLang = NULL; |
||
| 137 | foreach ($this->userLangs as $priority => $langcode) { |
||
| 138 | $this->langFilePath = $this->getConfigFilename($langcode); |
||
| 139 | if (file_exists($this->langFilePath)) { |
||
| 140 | $this->appliedLang = $langcode; |
||
| 141 | break; |
||
| 142 | } |
||
| 143 | } |
||
| 144 | if ($this->appliedLang == NULL) { |
||
| 145 | throw new \RuntimeException('No language file was found.'); |
||
| 146 | } |
||
| 147 | |||
| 148 | // search for cache file |
||
| 149 | $this->cacheFilePath = $this->cachePath . '/php_i18n_' . md5_file(__FILE__) . '_' . $this->prefix . '_' . $this->appliedLang . '.cache.php'; |
||
| 150 | |||
| 151 | // whether we need to create a new cache file |
||
| 152 | $outdated = !file_exists($this->cacheFilePath) || |
||
| 153 | filemtime($this->cacheFilePath) < filemtime($this->langFilePath) || // the language config was updated |
||
| 154 | ($this->mergeFallback && filemtime($this->cacheFilePath) < filemtime($this->getConfigFilename($this->fallbackLang))); // the fallback language config was updated |
||
| 155 | |||
| 156 | if ($outdated) { |
||
| 157 | $config = $this->load($this->langFilePath); |
||
| 158 | if ($this->mergeFallback) |
||
| 159 | $config = array_replace_recursive($this->load($this->getConfigFilename($this->fallbackLang)), $config); |
||
| 160 | |||
| 161 | $compiled = "<?php class " . $this->prefix . " {\n" |
||
| 162 | . $this->compile($config) |
||
| 163 | . 'public static function __callStatic($string, $args) {' . "\n" |
||
| 164 | . ' return vsprintf(constant("self::" . $string), $args);' |
||
| 165 | . "\n}\n}\n" |
||
| 166 | . $this->compileFunction(); |
||
| 167 | |||
| 206 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.