shawnrice/alphred

View on GitHub
classes/Alphred.php

Summary

Maintainability
C
1 day
Test Coverage

Function create_request has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
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,
Severity: Minor
Found in classes/Alphred.php - About 3 hrs to fix

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

class Alphred {

    /**
     * Initializes the wrapper object
     *
Severity: Minor
Found in classes/Alphred.php - About 3 hrs to fix

    Method create_request has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    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,
    Severity: Minor
    Found in classes/Alphred.php - About 1 hr to fix

      Function download has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      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
      Severity: Minor
      Found in classes/Alphred.php - About 55 mins to fix

      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

          private function create_request( $url, $options, $cache_ttl, $cache_bin, $type ) {
      Severity: Minor
      Found in classes/Alphred.php - About 35 mins to fix

        Method download has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function download( $url, $options = false, $cache_ttl = 0, $cache_bin = true, $destination = false ) {
        Severity: Minor
        Found in classes/Alphred.php - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status