mambax7/pedigree

View on GitHub
library/Zebra_Image.php

Summary

Maintainability
F
1 wk
Test Coverage

File Zebra_Image.php has 574 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 *  Methods used with the {@link resize()} method.
 */
Severity: Major
Found in library/Zebra_Image.php - About 1 day to fix

    Method resize has 189 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function resize($width = 0, $height = 0, $method = ZEBRA_IMAGE_CROP_CENTER, $background_color = -1)
        {
            // if image resource was successfully created
            if ($this->_create_from_source()) {
                // if either width or height is to be adjusted automatically
    Severity: Major
    Found in library/Zebra_Image.php - About 7 hrs to fix

      Function resize has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          public function resize($width = 0, $height = 0, $method = ZEBRA_IMAGE_CROP_CENTER, $background_color = -1)
          {
              // if image resource was successfully created
              if ($this->_create_from_source()) {
                  // if either width or height is to be adjusted automatically
      Severity: Minor
      Found in library/Zebra_Image.php - About 6 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

      Function apply_filter has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          public function apply_filter($filter, $arg1 = '', $arg2 = '', $arg3 = '', $arg4 = '')
          {
              // if "imagefilter" function exists and the requested filter exists
              if (function_exists('imagefilter')) // if image resource was successfully created
              {
      Severity: Minor
      Found in library/Zebra_Image.php - About 4 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

      Consider simplifying this complex logical expression.
      Open

                      if (
      
                          // aspect ratio needs to be preserved AND
                          ($this->preserve_aspect_ratio || isset($auto_preserve_aspect_ratio))
                          && // both width and height are given
      Severity: Critical
      Found in library/Zebra_Image.php - About 3 hrs to fix

        Function _create_from_source has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            private function _create_from_source()
            {
                // perform some error checking first
                // if the GD library is not installed
                if (!function_exists('gd_info')) {
        Severity: Minor
        Found in library/Zebra_Image.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

        Function rotate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function rotate($angle, $background_color = -1)
            {
                // get function arguments
                $arguments = func_get_args();
        
        
        Severity: Minor
        Found in library/Zebra_Image.php - About 2 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

        Method _create_from_source has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function _create_from_source()
            {
                // perform some error checking first
                // if the GD library is not installed
                if (!function_exists('gd_info')) {
        Severity: Major
        Found in library/Zebra_Image.php - About 2 hrs to fix

          Method _flip has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function _flip($orientation)
              {
                  // if image resource was successfully created
                  if ($this->_create_from_source()) {
                      // prepare the target image
          Severity: Minor
          Found in library/Zebra_Image.php - About 1 hr to fix

            Function _write_image has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                private function _write_image($identifier)
                {
                    // sharpen image if it's required
                    $this->_sharpen_image($identifier);
            
            
            Severity: Minor
            Found in library/Zebra_Image.php - About 1 hr 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 _write_image has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function _write_image($identifier)
                {
                    // sharpen image if it's required
                    $this->_sharpen_image($identifier);
            
            
            Severity: Minor
            Found in library/Zebra_Image.php - About 1 hr to fix

              Method rotate has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function rotate($angle, $background_color = -1)
                  {
                      // get function arguments
                      $arguments = func_get_args();
              
              
              Severity: Minor
              Found in library/Zebra_Image.php - About 1 hr to fix

                Consider simplifying this complex logical expression.
                Open

                                if ($width == 0 && $height > 0) {
                                    // get the original image's aspect ratio
                                    $aspect_ratio = $this->source_width / $this->source_height;
                
                                    // the target image's height is as given as argument to the method
                Severity: Critical
                Found in library/Zebra_Image.php - About 1 hr to fix

                  Method apply_filter has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function apply_filter($filter, $arg1 = '', $arg2 = '', $arg3 = '', $arg4 = '')
                      {
                          // if "imagefilter" function exists and the requested filter exists
                          if (function_exists('imagefilter')) // if image resource was successfully created
                          {
                  Severity: Minor
                  Found in library/Zebra_Image.php - About 1 hr to fix

                    Method crop has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function crop($start_x, $start_y, $end_x, $end_y)
                        {
                            // this method might be also called internally
                            // in this case, there's a fifth argument that points to an already existing image identifier
                            $args = func_get_args();
                    Severity: Minor
                    Found in library/Zebra_Image.php - About 1 hr to fix

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

                          public function apply_filter($filter, $arg1 = '', $arg2 = '', $arg3 = '', $arg4 = '')
                      Severity: Minor
                      Found in library/Zebra_Image.php - About 35 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                                    return $this->crop(
                        
                                                        $target_width - $width,
                                                        floor(($target_height - $height) / 2),
                                                        $target_width,
                        Severity: Major
                        Found in library/Zebra_Image.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                      return $this->crop(
                          
                                                          floor(($target_width - $width) / 2),
                                                          $target_height - $height,
                                                          floor(($target_width - $width) / 2) + $width,
                          Severity: Major
                          Found in library/Zebra_Image.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                        return $this->crop(
                            
                                                            $target_width - $width,
                                                            $target_height - $height,
                                                            $target_width,
                            Severity: Major
                            Found in library/Zebra_Image.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return false;
                              Severity: Major
                              Found in library/Zebra_Image.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return false;
                                Severity: Major
                                Found in library/Zebra_Image.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return $this->_write_image($target_identifier);
                                  Severity: Major
                                  Found in library/Zebra_Image.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                            return false;
                                    Severity: Major
                                    Found in library/Zebra_Image.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                                  return $this->crop(
                                      
                                                                      floor(($target_width - $width) / 2),
                                                                      floor(($target_height - $height) / 2),
                                                                      floor(($target_width - $width) / 2) + $width,
                                      Severity: Major
                                      Found in library/Zebra_Image.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                                    return $this->crop(
                                        
                                                                        0,
                                                                        $target_height - $height,
                                                                        $width,
                                        Severity: Major
                                        Found in library/Zebra_Image.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                              return $this->_write_image($target_identifier);
                                          Severity: Major
                                          Found in library/Zebra_Image.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                                return false;
                                            Severity: Major
                                            Found in library/Zebra_Image.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                              return false;
                                              Severity: Major
                                              Found in library/Zebra_Image.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                    return false;
                                                Severity: Major
                                                Found in library/Zebra_Image.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return true;
                                                  Severity: Major
                                                  Found in library/Zebra_Image.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                            return true;
                                                    Severity: Major
                                                    Found in library/Zebra_Image.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return false;
                                                      Severity: Major
                                                      Found in library/Zebra_Image.php - About 30 mins to fix

                                                        There are no issues that match your filters.

                                                        Category
                                                        Status