Function execute
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $code = false ) {
// Set a preliminary HTTP response code of 0 (not defined)
$this->code = 0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Request
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class Request {
/**
* The internal cURL handler
* @var Resource
Method execute
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $code = false ) {
// Set a preliminary HTTP response code of 0 (not defined)
$this->code = 0;
Function add_header
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function add_header( $header ) {
// Check the variable. We expect string, but let's be sure.
if ( is_string( $header ) ) {
// Since it's a string, just push it into the headers array.
array_push( $this->headers, $header );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function set_caches
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function set_caches( $options ) {
if ( ! isset( $options['cache_bin' ] ) ) {
// exit early if no cache bin is set
return;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return file_get_contents( $this->get_cache_file() );
Avoid too many return
statements within this method. Open
return [ 'code' => 0, 'data' => false ];
Avoid too many return
statements within this method. Open
return $this->results;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return [ 'code' => $this->code, 'data' => $this->results ];
Function clear_directory
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function clear_directory( $dir ) {
if ( ! file_exists( $dir ) || ! is_dir( $dir ) || '.' === $dir ) {
// Throw an exception because this is a bad request to clear the cache
throw new Exception( "Cannot clear directory: `{$dir}`", 3 );
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"