modxcms/revolution

View on GitHub
core/model/phpthumb/phpthumb.filters.php

Summary

Maintainability
F
2 wks
Test Coverage

File phpthumb.filters.php has 1201 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
//////////////////////////////////////////////////////////////
//   phpThumb() by James Heinrich <info@silisoftware.com>   //
//        available at http://phpthumb.sourceforge.net      //
//         and/or https://github.com/JamesHeinrich/phpThumb //
Severity: Major
Found in core/model/phpthumb/phpthumb.filters.php - About 3 days to fix

    Function WatermarkText has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
    Open

        public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000000', $ttffont='', $opacity=100, $margin=5, $angle=0, $bg_color=false, $bg_opacity=0, $fillextend='', $lineheight=1.0) {
            // text watermark requested
            if (!$text) {
                return false;
            }
    Severity: Minor
    Found in core/model/phpthumb/phpthumb.filters.php - About 1 day 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 WatermarkText has 250 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000000', $ttffont='', $opacity=100, $margin=5, $angle=0, $bg_color=false, $bg_opacity=0, $fillextend='', $lineheight=1.0) {
            // text watermark requested
            if (!$text) {
                return false;
            }
    Severity: Major
    Found in core/model/phpthumb/phpthumb.filters.php - About 1 day to fix

      Function DropShadow has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

          public function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha) {
              if (phpthumb_functions::gd_version() < 2) {
                  return false;
              }
              $distance =                 ($distance ? $distance : 10);
      Severity: Minor
      Found in core/model/phpthumb/phpthumb.filters.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 ImprovedImageRotate has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function ImprovedImageRotate(&$gdimg_source, $rotate_angle, $config_background_hexcolor, $bg, &$phpThumbObject) {
              while ($rotate_angle < 0) {
                  $rotate_angle += 360;
              }
              $rotate_angle %= 360;
      Severity: Minor
      Found in core/model/phpthumb/phpthumb.filters.php - About 5 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

      phpthumb_filters has 37 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class phpthumb_filters {
      
          /**
          * @var phpthumb
          */
      Severity: Minor
      Found in core/model/phpthumb/phpthumb.filters.php - About 4 hrs to fix

        Function WatermarkOverlay has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

            public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*', $opacity=50, $margin_x=5, $margin_y=null) {
        
                if ((is_resource($gdimg_dest) || (is_object($gdimg_dest) && $gdimg_dest instanceOf \GdImage)) && (is_resource($img_watermark) || (is_object($img_watermark) && $img_watermark instanceOf \GdImage))) {
                    $img_source_width          = imagesx($gdimg_dest);
                    $img_source_height         = imagesy($gdimg_dest);
        Severity: Minor
        Found in core/model/phpthumb/phpthumb.filters.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

        Method WatermarkOverlay has 91 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*', $opacity=50, $margin_x=5, $margin_y=null) {
        
                if ((is_resource($gdimg_dest) || (is_object($gdimg_dest) && $gdimg_dest instanceOf \GdImage)) && (is_resource($img_watermark) || (is_object($img_watermark) && $img_watermark instanceOf \GdImage))) {
                    $img_source_width          = imagesx($gdimg_dest);
                    $img_source_height         = imagesy($gdimg_dest);
        Severity: Major
        Found in core/model/phpthumb/phpthumb.filters.php - About 3 hrs to fix

          Function HistogramStretch has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              public function HistogramStretch(&$gdimg, $band='*', $method=0, $threshold=0.1) {
                  // equivalent of "Auto Contrast" in Adobe Photoshop
                  // method 0 stretches according to RGB colors. Gives a more conservative stretch.
                  // method 1 band stretches according to grayscale which is color-biased (59% green, 30% red, 11% blue). May give a punchier / more aggressive stretch, possibly appearing over-saturated
                  $Analysis = $this->HistogramAnalysis($gdimg, true);
          Severity: Minor
          Found in core/model/phpthumb/phpthumb.filters.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 ApplyMask has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              public function ApplyMask(&$gdimg_mask, &$gdimg_image) {
                  if (phpthumb_functions::gd_version() < 2) {
                      $this->DebugMessage('Skipping ApplyMask() because gd_version is "'.phpthumb_functions::gd_version().'"', __FILE__, __LINE__);
                      return false;
                  }
          Severity: Minor
          Found in core/model/phpthumb/phpthumb.filters.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 DropShadow has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha) {
                  if (phpthumb_functions::gd_version() < 2) {
                      return false;
                  }
                  $distance =                 ($distance ? $distance : 10);
          Severity: Major
          Found in core/model/phpthumb/phpthumb.filters.php - About 2 hrs to fix

            Method ImprovedImageRotate has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function ImprovedImageRotate(&$gdimg_source, $rotate_angle, $config_background_hexcolor, $bg, &$phpThumbObject) {
                    while ($rotate_angle < 0) {
                        $rotate_angle += 360;
                    }
                    $rotate_angle %= 360;
            Severity: Major
            Found in core/model/phpthumb/phpthumb.filters.php - About 2 hrs to fix

              Method HistogramStretch has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function HistogramStretch(&$gdimg, $band='*', $method=0, $threshold=0.1) {
                      // equivalent of "Auto Contrast" in Adobe Photoshop
                      // method 0 stretches according to RGB colors. Gives a more conservative stretch.
                      // method 1 band stretches according to grayscale which is color-biased (59% green, 30% red, 11% blue). May give a punchier / more aggressive stretch, possibly appearing over-saturated
                      $Analysis = $this->HistogramAnalysis($gdimg, true);
              Severity: Major
              Found in core/model/phpthumb/phpthumb.filters.php - About 2 hrs to fix

                Function ImageBorder has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function ImageBorder(&$gdimg, $border_width, $radius_x, $radius_y, $hexcolor_border) {
                        $border_width = ($border_width ? $border_width : 1);
                        $radius_x     = ($radius_x     ? $radius_x     : 0);
                        $radius_y     = ($radius_y     ? $radius_y     : 0);
                
                
                Severity: Minor
                Found in core/model/phpthumb/phpthumb.filters.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

                Function Colorize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function Colorize(&$gdimg, $amount, $targetColor) {
                        $amount      = (is_numeric($amount)                          ? $amount      : 25);
                        $amountPct   = $amount / 100;
                        $targetColor = (phpthumb_functions::IsHexColor($targetColor) ? $targetColor : 'gray');
                
                
                Severity: Minor
                Found in core/model/phpthumb/phpthumb.filters.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

                Function HistogramOverlay has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function HistogramOverlay(&$gdimg, $bands='*', $colors='', $width=0.25, $height=0.25, $alignment='BR', $opacity=50, $margin_x=5, $margin_y=null) {
                        $margin_y = (null === $margin_y ? $margin_x : $margin_y);
                
                        $Analysis = $this->HistogramAnalysis($gdimg, true);
                        $histW = round(($width > 1) ? min($width, imagesx($gdimg)) : imagesx($gdimg) * $width);
                Severity: Minor
                Found in core/model/phpthumb/phpthumb.filters.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 ImageBorder has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function ImageBorder(&$gdimg, $border_width, $radius_x, $radius_y, $hexcolor_border) {
                        $border_width = ($border_width ? $border_width : 1);
                        $radius_x     = ($radius_x     ? $radius_x     : 0);
                        $radius_y     = ($radius_y     ? $radius_y     : 0);
                
                
                Severity: Minor
                Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

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

                      public function Sepia(&$gdimg, $amount, $targetColor) {
                          $amount      = (is_numeric($amount) ? max(0, min(100, $amount)) : 50);
                          $amountPct   = $amount / 100;
                          $targetColor = (phpthumb_functions::IsHexColor($targetColor) ? $targetColor : 'A28065');
                  
                  
                  Severity: Minor
                  Found in core/model/phpthumb/phpthumb.filters.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 HistogramOverlay has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function HistogramOverlay(&$gdimg, $bands='*', $colors='', $width=0.25, $height=0.25, $alignment='BR', $opacity=50, $margin_x=5, $margin_y=null) {
                          $margin_y = (null === $margin_y ? $margin_x : $margin_y);
                  
                          $Analysis = $this->HistogramAnalysis($gdimg, true);
                          $histW = round(($width > 1) ? min($width, imagesx($gdimg)) : imagesx($gdimg) * $width);
                  Severity: Minor
                  Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                    Method WatermarkText has 13 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function WatermarkText(&$gdimg, $text, $size, $alignment, $hex_color='000000', $ttffont='', $opacity=100, $margin=5, $angle=0, $bg_color=false, $bg_opacity=0, $fillextend='', $lineheight=1.0) {
                    Severity: Major
                    Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                      Function Flip has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function Flip(&$gdimg, $x=false, $y=false) {
                              if (!$x && !$y) {
                                  return false;
                              }
                              if ($tempImage = phpthumb_functions::ImageCreateFunction(imagesx($gdimg), imagesy($gdimg))) {
                      Severity: Minor
                      Found in core/model/phpthumb/phpthumb.filters.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

                      Function Contrast has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function Contrast(&$gdimg, $amount=0) {
                              if ($amount == 0) {
                                  return true;
                              }
                              $amount = max(-255, min(255, $amount));
                      Severity: Minor
                      Found in core/model/phpthumb/phpthumb.filters.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 Colorize has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function Colorize(&$gdimg, $amount, $targetColor) {
                              $amount      = (is_numeric($amount)                          ? $amount      : 25);
                              $amountPct   = $amount / 100;
                              $targetColor = (phpthumb_functions::IsHexColor($targetColor) ? $targetColor : 'gray');
                      
                      
                      Severity: Minor
                      Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                        Method Sepia has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function Sepia(&$gdimg, $amount, $targetColor) {
                                $amount      = (is_numeric($amount) ? max(0, min(100, $amount)) : 50);
                                $amountPct   = $amount / 100;
                                $targetColor = (phpthumb_functions::IsHexColor($targetColor) ? $targetColor : 'A28065');
                        
                        
                        Severity: Minor
                        Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                          Method ApplyMask has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function ApplyMask(&$gdimg_mask, &$gdimg_image) {
                                  if (phpthumb_functions::gd_version() < 2) {
                                      $this->DebugMessage('Skipping ApplyMask() because gd_version is "'.phpthumb_functions::gd_version().'"', __FILE__, __LINE__);
                                      return false;
                                  }
                          Severity: Minor
                          Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                            Consider simplifying this complex logical expression.
                            Open

                                    if ((is_resource($gdimg_dest) || (is_object($gdimg_dest) && $gdimg_dest instanceOf \GdImage)) && (is_resource($img_watermark) || (is_object($img_watermark) && $img_watermark instanceOf \GdImage))) {
                                        $img_source_width          = imagesx($gdimg_dest);
                                        $img_source_height         = imagesy($gdimg_dest);
                                        $watermark_source_width    = imagesx($img_watermark);
                                        $watermark_source_height   = imagesy($img_watermark);
                            Severity: Critical
                            Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                              Method WhiteBalance has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function WhiteBalance(&$gdimg, $targetColor='') {
                                      if (phpthumb_functions::IsHexColor($targetColor)) {
                                          $targetPixel = array(
                                              'red'   => hexdec(substr($targetColor, 0, 2)),
                                              'green' => hexdec(substr($targetColor, 2, 2)),
                              Severity: Minor
                              Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                                Function Brightness has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    public function Brightness(&$gdimg, $amount=0) {
                                        if ($amount == 0) {
                                            return true;
                                        }
                                        $amount = max(-255, min(255, $amount));
                                Severity: Minor
                                Found in core/model/phpthumb/phpthumb.filters.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 HistogramOverlay has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    public function HistogramOverlay(&$gdimg, $bands='*', $colors='', $width=0.25, $height=0.25, $alignment='BR', $opacity=50, $margin_x=5, $margin_y=null) {
                                Severity: Major
                                Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                                  Method Contrast has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function Contrast(&$gdimg, $amount=0) {
                                          if ($amount == 0) {
                                              return true;
                                          }
                                          $amount = max(-255, min(255, $amount));
                                  Severity: Minor
                                  Found in core/model/phpthumb/phpthumb.filters.php - About 1 hr to fix

                                    Function Crop has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function Crop(&$gdimg, $left=0, $right=0, $top=0, $bottom=0) {
                                            if (!$left && !$right && !$top && !$bottom) {
                                                return true;
                                            }
                                            $oldW = imagesx($gdimg);
                                    Severity: Minor
                                    Found in core/model/phpthumb/phpthumb.filters.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

                                    Function HistogramAnalysis has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function HistogramAnalysis(&$gdimg, $calculateGray=false) {
                                            $ImageSX = imagesx($gdimg);
                                            $ImageSY = imagesy($gdimg);
                                            $Analysis = array();
                                            for ($x = 0; $x < $ImageSX; $x++) {
                                    Severity: Minor
                                    Found in core/model/phpthumb/phpthumb.filters.php - About 45 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

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if (!isset($PixelMap[$x][$y]['alpha']) || ($PixelMap[$x][$y]['alpha'] > 0)) {
                                                                if (isset($PixelMap[$x + (int)$Offset['x']][$y + (int)$Offset['y']]['alpha']) && ($PixelMap[$x + (int)$Offset['x']][$y + (int)$Offset['y']]['alpha'] < 127)) {
                                                                    $thisColor = phpthumb_functions::ImageHexColorAllocate($gdimg, $hexcolor, false, $PixelMap[$x + (int)$Offset['x']][$y + (int)$Offset['y']]['alpha']);
                                                                    imagesetpixel($gdimg_dropshadow_temp, $x, $y, $thisColor);
                                                                }
                                    Severity: Major
                                    Found in core/model/phpthumb/phpthumb.filters.php - About 45 mins to fix

                                      Method WatermarkOverlay has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          public function WatermarkOverlay(&$gdimg_dest, &$img_watermark, $alignment='*', $opacity=50, $margin_x=5, $margin_y=null) {
                                      Severity: Minor
                                      Found in core/model/phpthumb/phpthumb.filters.php - About 45 mins to fix

                                        Method Frame has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                            public function Frame(&$gdimg, $frame_width, $edge_width, $hexcolor_frame, $hexcolor1, $hexcolor2) {
                                        Severity: Minor
                                        Found in core/model/phpthumb/phpthumb.filters.php - About 45 mins to fix

                                          Method DropShadow has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              public function DropShadow(&$gdimg, $distance, $width, $hexcolor, $angle, $alpha) {
                                          Severity: Minor
                                          Found in core/model/phpthumb/phpthumb.filters.php - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                                            for ($y = $watermark_margin_y; $y < ($img_source_height + $watermark_source_height); $y += ($watermark_source_height + $watermark_margin_y)) {
                                                                                imagecopy(
                                                                                    $gdimg_tiledwatermark,
                                                                                    $img_watermark,
                                                                                    $x,
                                            Severity: Major
                                            Found in core/model/phpthumb/phpthumb.filters.php - About 45 mins to fix

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

                                                  public static function ImprovedImageRotate(&$gdimg_source, $rotate_angle, $config_background_hexcolor, $bg, &$phpThumbObject) {
                                              Severity: Minor
                                              Found in core/model/phpthumb/phpthumb.filters.php - About 35 mins to fix

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

                                                    public function Crop(&$gdimg, $left=0, $right=0, $top=0, $bottom=0) {
                                                Severity: Minor
                                                Found in core/model/phpthumb/phpthumb.filters.php - About 35 mins to fix

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

                                                      public function ImageBorder(&$gdimg, $border_width, $radius_x, $radius_y, $hexcolor_border) {
                                                  Severity: Minor
                                                  Found in core/model/phpthumb/phpthumb.filters.php - About 35 mins to fix

                                                    Function Threshold has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function Threshold(&$gdimg, $cutoff) {
                                                            $width  = imagesx($gdimg);
                                                            $height = imagesy($gdimg);
                                                            $cutoff = min(255, max(0, ($cutoff ? $cutoff : 128)));
                                                            for ($x = 0; $x < $width; $x++) {
                                                    Severity: Minor
                                                    Found in core/model/phpthumb/phpthumb.filters.php - About 35 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

                                                    Function Negative has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function Negative(&$gdimg) {
                                                            if (phpthumb_functions::version_compare_replacement(PHP_VERSION, '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
                                                                if (imagefilter($gdimg, IMG_FILTER_NEGATE)) {
                                                                    return true;
                                                                }
                                                    Severity: Minor
                                                    Found in core/model/phpthumb/phpthumb.filters.php - About 35 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

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

                                                        public function Ellipse($gdimg) {
                                                            if (phpthumb_functions::gd_version() < 2) {
                                                                return false;
                                                            }
                                                            // generate mask at twice desired resolution and downsample afterwards for easy antialiasing
                                                    Severity: Minor
                                                    Found in core/model/phpthumb/phpthumb.filters.php - About 25 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

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

                                                        public function SourceTransparentColorMask(&$gdimg, $hexcolor, $min_limit=5, $max_limit=10) {
                                                            $width  = imagesx($gdimg);
                                                            $height = imagesy($gdimg);
                                                            if ($gdimg_mask = imagecreatetruecolor($width, $height)) {
                                                                $R = hexdec(substr($hexcolor, 0, 2));
                                                    Severity: Minor
                                                    Found in core/model/phpthumb/phpthumb.filters.php - About 25 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

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                                    if (phpthumb_functions::IsHexColor($bg_color)) {
                                                                        $text_background_alpha = round(127 * ((100 - min(max(0, $bg_opacity), 100)) / 100));
                                                                        $text_color_background = phpthumb_functions::ImageHexColorAllocate($img_watermark, $bg_color, false, $text_background_alpha);
                                                                    } else {
                                                                        $text_color_background = phpthumb_functions::ImageHexColorAllocate($img_watermark, 'FFFFFF', false, 127);
                                                    Severity: Major
                                                    Found in core/model/phpthumb/phpthumb.filters.php and 1 other location - About 1 hr to fix
                                                    core/model/phpthumb/phpthumb.filters.php on lines 1249..1254

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 113.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                                    Open

                                                                    if (phpthumb_functions::IsHexColor($bg_color)) {
                                                                        $text_background_alpha = round(127 * ((100 - min(max(0, $bg_opacity), 100)) / 100));
                                                                        $text_color_background = phpthumb_functions::ImageHexColorAllocate($gdimg, $bg_color, false, $text_background_alpha);
                                                                    } else {
                                                                        $text_color_background = phpthumb_functions::ImageHexColorAllocate($gdimg, 'FFFFFF', false, 127);
                                                    Severity: Major
                                                    Found in core/model/phpthumb/phpthumb.filters.php and 1 other location - About 1 hr to fix
                                                    core/model/phpthumb/phpthumb.filters.php on lines 1322..1327

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 113.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 4 locations. Consider refactoring.
                                                    Open

                                                        public function EdgeDetect(&$gdimg) {
                                                            if (phpthumb_functions::version_compare_replacement(PHP_VERSION, '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
                                                                if (imagefilter($gdimg, IMG_FILTER_EDGEDETECT)) {
                                                                    return true;
                                                                }
                                                    Severity: Major
                                                    Found in core/model/phpthumb/phpthumb.filters.php and 3 other locations - About 55 mins to fix
                                                    core/model/phpthumb/phpthumb.filters.php on lines 147..158
                                                    core/model/phpthumb/phpthumb.filters.php on lines 440..451
                                                    core/model/phpthumb/phpthumb.filters.php on lines 854..865

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 98.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 4 locations. Consider refactoring.
                                                    Open

                                                        public function MeanRemoval(&$gdimg) {
                                                            if (phpthumb_functions::version_compare_replacement(PHP_VERSION, '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
                                                                if (imagefilter($gdimg, IMG_FILTER_MEAN_REMOVAL)) {
                                                                    return true;
                                                                }
                                                    Severity: Major
                                                    Found in core/model/phpthumb/phpthumb.filters.php and 3 other locations - About 55 mins to fix
                                                    core/model/phpthumb/phpthumb.filters.php on lines 147..158
                                                    core/model/phpthumb/phpthumb.filters.php on lines 399..410
                                                    core/model/phpthumb/phpthumb.filters.php on lines 440..451

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 98.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 4 locations. Consider refactoring.
                                                    Open

                                                        public function Emboss(&$gdimg) {
                                                            if (phpthumb_functions::version_compare_replacement(PHP_VERSION, '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
                                                                if (imagefilter($gdimg, IMG_FILTER_EMBOSS)) {
                                                                    return true;
                                                                }
                                                    Severity: Major
                                                    Found in core/model/phpthumb/phpthumb.filters.php and 3 other locations - About 55 mins to fix
                                                    core/model/phpthumb/phpthumb.filters.php on lines 147..158
                                                    core/model/phpthumb/phpthumb.filters.php on lines 399..410
                                                    core/model/phpthumb/phpthumb.filters.php on lines 854..865

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 98.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    Similar blocks of code found in 4 locations. Consider refactoring.
                                                    Open

                                                        public function BlurSelective(&$gdimg) {
                                                            if (phpthumb_functions::version_compare_replacement(PHP_VERSION, '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
                                                                if (imagefilter($gdimg, IMG_FILTER_SELECTIVE_BLUR)) {
                                                                    return true;
                                                                }
                                                    Severity: Major
                                                    Found in core/model/phpthumb/phpthumb.filters.php and 3 other locations - About 55 mins to fix
                                                    core/model/phpthumb/phpthumb.filters.php on lines 399..410
                                                    core/model/phpthumb/phpthumb.filters.php on lines 440..451
                                                    core/model/phpthumb/phpthumb.filters.php on lines 854..865

                                                    Duplicated Code

                                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                    Tuning

                                                    This issue has a mass of 98.

                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                    Refactorings

                                                    Further Reading

                                                    There are no issues that match your filters.

                                                    Category
                                                    Status