fucongcong/framework

View on GitHub
core/Group/Cache/LocalFileCacheService.php

Summary

Maintainability
A
25 mins
Test Coverage

Showing 16 of 16 total issues

Function set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

public function set($cacheName, $data, $cacheDir = false, $flag = false)
{
$cacheDir = $cacheDir == false ? self::$cacheDir : $cacheDir;
if (defined('__FILEROOT__')) {
$dir = __FILEROOT__;
Severity: Minor
Found in core/Group/Cache/LocalFileCacheService.php - About 25 mins to fix

Avoid using undefined variables such as '$cacheName' which will lead to PHP notices.
Open

$dir = $dir.$cacheDir."/".$cacheName;

The method get has a boolean flag argument $cacheDir, which is a certain sign of a Single Responsibility Principle violation.
Open

public function get($cacheName, $cacheDir = false)

The method isExist has a boolean flag argument $cacheDir, which is a certain sign of a Single Responsibility Principle violation.
Open

public function isExist($cacheName, $cacheDir = false)

The method set has a boolean flag argument $cacheDir, which is a certain sign of a Single Responsibility Principle violation.
Open

public function set($cacheName, $data, $cacheDir = false, $flag = false)

The method set has a boolean flag argument $flag, which is a certain sign of a Single Responsibility Principle violation.
Open

public function set($cacheName, $data, $cacheDir = false, $flag = false)

Remove error control operator '@' on line 95.
Open

public function remove($filename, $cacheDir = false)
{
$cacheDir = $cacheDir == false ? self::$cacheDir : $cacheDir;
if (defined('__FILEROOT__')) {
$dir = __FILEROOT__;

The method remove has a boolean flag argument $cacheDir, which is a certain sign of a Single Responsibility Principle violation.
Open

public function remove($filename, $cacheDir = false)

The method isExist uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

} else {
$dir = __ROOT__;
}

The method set uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

} else {
$dir = __ROOT__;
}

The method get uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

} else {
$dir = __ROOT__;
}

The method remove uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

} else {
$dir = __ROOT__;
}

Avoid unused local variables such as '$cacheName'.
Open

$dir = $dir.$cacheDir."/".$cacheName;

Avoid unused parameters such as '$filename'.
Open

public function remove($filename, $cacheDir = false)

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}

Inline control structures are not allowed
Open

if ($this->isExist($cacheName, $cacheDir)) return require_once $dir;
Category
Status