| Conditions | 26 |
| Paths | 7403 |
| Total Lines | 73 |
| Code Lines | 42 |
| 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 |
||
| 33 | public function getPath($getBasePath = false) |
||
| 34 | { |
||
| 35 | $tmp_dir = rtrim(ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(), '\\/') . DIRECTORY_SEPARATOR . 'phpfastcache'; |
||
| 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 | return $path; |
||
| 55 | } |
||
| 56 | |||
| 57 | $securityKey = array_key_exists('securityKey', $this->config) ? $this->config[ 'securityKey' ] : ''; |
||
| 58 | if (!$securityKey || $securityKey === 'auto') { |
||
| 59 | if (isset($_SERVER[ 'HTTP_HOST' ])) { |
||
| 60 | $securityKey = preg_replace('/^www./', '', strtolower(str_replace(':', '_', $_SERVER[ 'HTTP_HOST' ]))); |
||
| 61 | } else { |
||
| 62 | $securityKey = ($this->isPHPModule() ? 'web' : 'cli'); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | if ($securityKey !== '') { |
||
| 67 | $securityKey .= '/'; |
||
| 68 | } |
||
| 69 | |||
| 70 | $securityKey = static::cleanFileName($securityKey); |
||
| 71 | |||
| 72 | $full_path = rtrim($path, '/') . '/' . $securityKey; |
||
| 73 | $full_pathx = md5($full_path); |
||
| 74 | |||
| 75 | |||
| 76 | if (!isset($this->tmp[ $full_pathx ])) { |
||
| 77 | |||
| 78 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
||
| 79 | if (!@file_exists($full_path)) { |
||
| 80 | @mkdir($full_path, $this->setChmodAuto(), true); |
||
|
1 ignored issue
–
show
|
|||
| 81 | } |
||
| 82 | if (!@is_writable($full_path)) { |
||
| 83 | @chmod($full_path, $this->setChmodAuto()); |
||
|
1 ignored issue
–
show
|
|||
| 84 | } |
||
| 85 | if (!@is_writable($full_path)) { |
||
| 86 | // switch back to tmp dir again if the path is not writeable |
||
| 87 | $full_path = rtrim($tmp_dir, '/') . '/' . $securityKey; |
||
| 88 | if (!@file_exists($full_path)) { |
||
| 89 | @mkdir($full_path, $this->setChmodAuto(), true); |
||
|
1 ignored issue
–
show
|
|||
| 90 | } |
||
| 91 | if (!@is_writable($full_path)) { |
||
| 92 | @chmod($full_path, $this->setChmodAuto()); |
||
|
1 ignored issue
–
show
|
|||
| 93 | } |
||
| 94 | } |
||
| 95 | if (!@file_exists($full_path) || !@is_writable($full_path)) { |
||
| 96 | throw new phpFastCacheCoreException('PLEASE CREATE OR CHMOD ' . $full_path . ' - 0777 OR ANY WRITABLE PERMISSION!', 92); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | $this->tmp[ $full_pathx ] = true; |
||
| 101 | $this->htaccessGen($full_path, array_key_exists('htaccess', $this->config) ? $this->config[ 'htaccess' ] : false); |
||
| 102 | } |
||
| 103 | |||
| 104 | return realpath($full_path); |
||
| 105 | } |
||
| 106 | |||
| 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.