| Conditions | 27 |
| Paths | 14806 |
| Total Lines | 72 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 2 | 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 |
||
| 33 | public function getPath($getBasePath = false) |
||
| 34 | { |
||
| 35 | $tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(); |
||
| 36 | |||
| 37 | if (!isset($this->config[ 'path' ]) || $this->config[ 'path' ] == '') { |
||
| 38 | if (self::isPHPModule()) { |
||
| 39 | $path = $tmp_dir; |
||
| 40 | } else { |
||
| 41 | $document_root_path = rtrim($_SERVER[ 'DOCUMENT_ROOT' ], '/') . '/../'; |
||
| 42 | $path = isset($_SERVER[ 'DOCUMENT_ROOT' ]) && is_writable($document_root_path) ? $document_root_path : rtrim(__DIR__, '/') . '/'; |
||
| 43 | } |
||
| 44 | |||
| 45 | if ($this->config[ 'path' ] != '') { |
||
| 46 | $path = $this->config[ 'path' ]; |
||
|
1 ignored issue
–
show
|
|||
| 47 | } |
||
| 48 | |||
| 49 | } else { |
||
| 50 | $path = $this->config[ 'path' ]; |
||
| 51 | } |
||
| 52 | |||
| 53 | if($getBasePath === true) |
||
| 54 | { |
||
| 55 | return $path; |
||
| 56 | } |
||
| 57 | |||
| 58 | $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
||
| 59 | if ($securityKey == "" || $securityKey == 'auto') { |
||
| 60 | $securityKey = $this->config[ 'securityKey' ]; |
||
| 61 | if ($securityKey == 'auto' || $securityKey == '') { |
||
| 62 | $securityKey = isset($_SERVER[ 'HTTP_HOST' ]) ? preg_replace('/^www./', '', strtolower($_SERVER[ 'HTTP_HOST' ])) : "default"; |
||
| 63 | } |
||
| 64 | } |
||
| 65 | if ($securityKey != '') { |
||
| 66 | $securityKey .= '/'; |
||
| 67 | } |
||
| 68 | |||
| 69 | $securityKey = $this->cleanFileName($securityKey); |
||
| 70 | |||
| 71 | $full_path = rtrim($path, '/') .'/' . $securityKey; |
||
| 72 | $full_pathx = md5($full_path); |
||
| 73 | |||
| 74 | |||
| 75 | if (!isset($this->tmp[ $full_pathx ])) { |
||
| 76 | |||
| 77 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
||
| 78 | if (!@file_exists($full_path)) { |
||
| 79 | @mkdir($full_path, $this->setChmodAuto(), true); |
||
|
1 ignored issue
–
show
|
|||
| 80 | } |
||
| 81 | if (!@is_writable($full_path)) { |
||
| 82 | @chmod($full_path, $this->setChmodAuto()); |
||
|
1 ignored issue
–
show
|
|||
| 83 | } |
||
| 84 | if (!@is_writable($full_path)) { |
||
| 85 | // switch back to tmp dir again if the path is not writeable |
||
| 86 | $full_path = rtrim($tmp_dir, '/') . '/' . $securityKey; |
||
| 87 | if (!@file_exists($full_path)) { |
||
| 88 | @mkdir($full_path, $this->setChmodAuto(), true); |
||
|
1 ignored issue
–
show
|
|||
| 89 | } |
||
| 90 | if (!@is_writable($full_path)) { |
||
| 91 | @chmod($full_path, $this->setChmodAuto()); |
||
|
1 ignored issue
–
show
|
|||
| 92 | } |
||
| 93 | } |
||
| 94 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
||
| 95 | throw new phpFastCacheCoreException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!', 92); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | $this->tmp[ $full_pathx ] = true; |
||
| 100 | $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
||
| 101 | } |
||
| 102 | |||
| 103 | return realpath($full_path); |
||
| 104 | } |
||
| 105 | |||
| 229 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.