| Conditions | 23 |
| Paths | 198 |
| Total Lines | 60 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | 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 |
||
| 120 | public function getIncludePath($dirs, $file, Smarty $smarty) |
||
| 121 | { |
||
| 122 | //if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) { |
||
| 123 | if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : |
||
| 124 | $this->_has_stream_include = function_exists('stream_resolve_include_path')) |
||
| 125 | ) { |
||
| 126 | $this->isNewIncludePath($smarty); |
||
| 127 | } |
||
| 128 | // try PHP include_path |
||
| 129 | foreach ($dirs as $dir) { |
||
| 130 | $dir_n = isset($this->number[ $dir ]) ? $this->number[ $dir ] : $this->number[ $dir ] = $this->counter++; |
||
| 131 | if (isset($this->isFile[ $dir_n ][ $file ])) { |
||
| 132 | if ($this->isFile[ $dir_n ][ $file ]) { |
||
| 133 | return $this->isFile[ $dir_n ][ $file ]; |
||
| 134 | } else { |
||
| 135 | continue; |
||
| 136 | } |
||
| 137 | } |
||
| 138 | if (isset($this->_user_dirs[ $dir_n ])) { |
||
| 139 | if (false === $this->_user_dirs[ $dir_n ]) { |
||
| 140 | continue; |
||
| 141 | } else { |
||
| 142 | $dir = $this->_user_dirs[ $dir_n ]; |
||
| 143 | } |
||
| 144 | } else { |
||
| 145 | if ($dir[ 0 ] === '/' || $dir[ 1 ] === ':') { |
||
| 146 | $dir = str_ireplace(getcwd(), '.', $dir); |
||
| 147 | if ($dir[ 0 ] === '/' || $dir[ 1 ] === ':') { |
||
| 148 | $this->_user_dirs[ $dir_n ] = false; |
||
| 149 | continue; |
||
| 150 | } |
||
| 151 | } |
||
| 152 | $dir = substr($dir, 2); |
||
|
|
|||
| 153 | $this->_user_dirs[ $dir_n ] = $dir; |
||
| 154 | } |
||
| 155 | if ($this->_has_stream_include) { |
||
| 156 | $path = stream_resolve_include_path($dir . (isset($file) ? $file : '')); |
||
| 157 | if ($path) { |
||
| 158 | return $this->isFile[ $dir_n ][ $file ] = $path; |
||
| 159 | } |
||
| 160 | } else { |
||
| 161 | foreach ($this->_include_dirs as $key => $_i_path) { |
||
| 162 | $path = isset($this->isPath[ $key ][ $dir_n ]) ? $this->isPath[ $key ][ $dir_n ] : |
||
| 163 | $this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false; |
||
| 164 | if ($path === false) { |
||
| 165 | continue; |
||
| 166 | } |
||
| 167 | if (isset($file)) { |
||
| 168 | $_file = $this->isFile[ $dir_n ][ $file ] = (is_file($path . $file)) ? $path . $file : false; |
||
| 169 | if ($_file) { |
||
| 170 | return $_file; |
||
| 171 | } |
||
| 172 | } else { |
||
| 173 | // no file was given return directory path |
||
| 174 | return $path; |
||
| 175 | } |
||
| 176 | } |
||
| 177 | } |
||
| 178 | } |
||
| 179 | return false; |
||
| 180 | } |
||
| 182 |