| Conditions | 13 |
| Paths | 576 |
| Total Lines | 64 |
| 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 |
||
| 40 | public function view($file, $data = [], $return = FALSE) { |
||
| 41 | |||
| 42 | // Delete double .tpl.tpl |
||
| 43 | //TODO remove this and find root of problem |
||
| 44 | if (false !== strpos($file, '.tpl.tpl')) { |
||
| 45 | $file = substr($file, 0, -4); |
||
| 46 | } |
||
| 47 | |||
| 48 | if (preg_match('/file:/', $file, $_Matches)) { |
||
| 49 | $file_dir = preg_replace('/\/\//', '/', $file); |
||
| 50 | $file_dir = preg_replace('/file\:/', '', $file_dir); |
||
| 51 | } elseif (preg_match('/dir:/', $file, $_Matches)) { |
||
| 52 | $file_dir = preg_replace('/\/\//', '/', $file); |
||
| 53 | $file_dir = preg_replace('/dir\:/', '', $file_dir); |
||
| 54 | } else { |
||
| 55 | $file_dir = $this->config->tpl_path . $file; |
||
| 56 | } |
||
| 57 | $all_tpl_path = $this->config->tpl_path . 'shop/default/'; |
||
| 58 | //if (preg_match('/application\/modules/', $file_dir, $mm)) |
||
| 59 | if (strpos($file_dir, 'application\modules')) { |
||
| 60 | $newFile = explode('application\modules', $file_dir); |
||
| 61 | $new_file_dir = $all_tpl_path . 'modules' . $newFile[1]; |
||
| 62 | |||
| 63 | if (file_exists($new_file_dir)) { |
||
| 64 | $file_dir = $new_file_dir; |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | $compiled_file = $this->config->compile_path . md5($file_dir) . $this->config->compiled_ext; |
||
| 69 | |||
| 70 | if (!file_exists($compiled_file) OR $this->config->force_compile == TRUE) { |
||
| 71 | // Compile file |
||
| 72 | $this->load_compiler(); |
||
| 73 | $this->compiler->compile($file_dir); |
||
| 74 | } |
||
| 75 | |||
| 76 | extract($data); |
||
| 77 | |||
| 78 | ob_start(); |
||
| 79 | |||
| 80 | if (file_exists($compiled_file)) { |
||
| 81 | include $compiled_file; |
||
| 82 | } else { |
||
| 83 | print '<p class="error">Error: ' . $compiled_file . ' does not exists!</p>'; |
||
| 84 | } |
||
| 85 | |||
| 86 | // Time to live expried |
||
| 87 | /* @var $mabilis_ttl integer */ |
||
| 88 | if ($mabilis_ttl <= time()) { |
||
| 89 | @unlink($compiled_file); |
||
| 90 | } |
||
| 91 | |||
| 92 | if ($this->config->use_filemtime == TRUE AND $mabilis_last_modified != @filemtime($file_dir)) { |
||
| 93 | @unlink($compiled_file); |
||
| 94 | } |
||
| 95 | |||
| 96 | if ($return == TRUE) { |
||
| 97 | $buffer = ob_get_contents(); |
||
| 98 | ob_end_clean(); |
||
| 99 | return $buffer; |
||
| 100 | } |
||
| 101 | |||
| 102 | ob_end_flush(); |
||
| 103 | } |
||
| 104 | |||
| 160 | /* End of Mabilis.class.php */ |
This check compares the return type specified in the
@returnannotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.