classes/Alphred.php
Function create_request
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
Open
private function create_request( $url, $options, $cache_ttl, $cache_bin, $type ) {
if ( $cache_ttl > 0 ) {
// Create an object with caching on
$request = new Alphred\Request( $url, [ 'cache' => true,
- 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
Alphred
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Alphred {
/**
* Initializes the wrapper object
*
Method create_request
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function create_request( $url, $options, $cache_ttl, $cache_bin, $type ) {
if ( $cache_ttl > 0 ) {
// Create an object with caching on
$request = new Alphred\Request( $url, [ 'cache' => true,
Function download
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
public function download( $url, $options = false, $cache_ttl = 0, $cache_bin = true, $destination = false ) {
$request = $this->create_request( $url, $options, $cache_ttl, $cache_bin, 'get' );
$request->execute();
// If a destination path has been set, then rename the cache file to the destination path after downloading it
- 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
Method create_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
private function create_request( $url, $options, $cache_ttl, $cache_bin, $type ) {
Method download
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function download( $url, $options = false, $cache_ttl = 0, $cache_bin = true, $destination = false ) {