mambax7/tdmdownloads

View on GitHub
class/Common/ImageResizer.php

Summary

Maintainability
D
1 day
Test Coverage

Function resizeImage has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $imageMimetype)
    {
        // check file extension
        switch ($imageMimetype) {
            case 'image/png':
Severity: Minor
Found in class/Common/ImageResizer.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 resizeImage has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $imageMimetype)
    {
        // check file extension
        switch ($imageMimetype) {
            case 'image/png':
Severity: Major
Found in class/Common/ImageResizer.php - About 2 hrs to fix

    Method resizeAndCrop has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest_h, $quality = 90)
        {
            // check file extension
            switch ($src_mimetype) {
                case 'image/png':
    Severity: Minor
    Found in class/Common/ImageResizer.php - About 2 hrs to fix

      Function mergeImage has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function mergeImage($src_url, $dest_url, $pos, $of)
          {
              $dest = \imagecreatefromjpeg($dest_url);
              $src  = \imagecreatefromjpeg($src_url);
              // ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
      Severity: Minor
      Found in class/Common/ImageResizer.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 mergeImage has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function mergeImage($src_url, $dest_url, $pos, $of)
          {
              $dest = \imagecreatefromjpeg($dest_url);
              $src  = \imagecreatefromjpeg($src_url);
              // ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
      Severity: Minor
      Found in class/Common/ImageResizer.php - About 1 hr to fix

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

            public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest_h, $quality = 90)
            {
                // check file extension
                switch ($src_mimetype) {
                    case 'image/png':
        Severity: Minor
        Found in class/Common/ImageResizer.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 resizeAndCrop has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function resizeAndCrop($src_url, $src_mimetype, $dest_url, $dest_w, $dest_h, $quality = 90)
        Severity: Minor
        Found in class/Common/ImageResizer.php - About 45 mins to fix

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

              public function resizeImage($sourcefile, $endfile, $max_width, $max_height, $imageMimetype)
          Severity: Minor
          Found in class/Common/ImageResizer.php - About 35 mins to fix

            Avoid too many return statements within this method.
            Open

                        return false;
            Severity: Major
            Found in class/Common/ImageResizer.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return true;
              Severity: Major
              Found in class/Common/ImageResizer.php - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status