autowp/image

View on GitHub

Showing 100 of 100 total issues

File Storage.php has 1026 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
 
declare(strict_types=1);
 
namespace Autowp\Image;
Severity: Major
Found in src/Storage.php - About 2 days to fix

    File Sampler.php has 558 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
     
    declare(strict_types=1);
     
    namespace Autowp\Image;
    Severity: Major
    Found in src/Sampler.php - About 1 day to fix

      Storage has 53 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Storage implements StorageInterface
      {
      private const EXTENSION_DEFAULT = 'jpg';
       
      private const INSERT_MAX_ATTEMPTS = 15;
      Severity: Major
      Found in src/Storage.php - About 7 hrs to fix

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

        public function normalize(int $imageId): void
        {
        $imageRow = $this->getImageRow($imageId);
         
        if (! $imageRow) {
        Severity: Major
        Found in src/Storage.php and 1 other location - About 6 hrs to fix
        src/Storage.php on lines 1249..1287

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

        public function flop(int $imageId): void
        {
        $imageRow = $this->getImageRow($imageId);
         
        if (! $imageRow) {
        Severity: Major
        Found in src/Storage.php and 1 other location - About 6 hrs to fix
        src/Storage.php on lines 1293..1331

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

        if ($format->isReduceOnly() && $sizeLess) {
        // dont crop
        if (! $heightLess) {
        // resize by height
        $scaleHeight = $formatHeight;
        Severity: Major
        Found in src/Sampler.php and 1 other location - About 6 hrs to fix
        src/Sampler.php on lines 170..194

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

        if ($format->isReduceOnly() && $sizeLess) {
        if (! $heightLess) {
        // resize by height
        $scaleHeight = $formatHeight;
        $scaleWidth = (int) round($scaleHeight * $srcRatio);
        Severity: Major
        Found in src/Sampler.php and 1 other location - About 6 hrs to fix
        src/Sampler.php on lines 111..136

        Method doFormatImage has 116 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        private function doFormatImage(int $imageId, string $formatName): int
        {
        // find source image
        /** @var ResultSet $resultSet */
        $resultSet = $this->imageTable->select([
        Severity: Major
        Found in src/Storage.php - About 4 hrs to fix

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

          public function convertImagick(Imagick $imagick, ?array $crop, $format): Imagick
          {
          if (! $format instanceof Sampler\Format) {
          if (! is_array($format)) {
          throw new Sampler\Exception("Unexpected type of format");
          Severity: Minor
          Found in src/Sampler.php - About 4 hrs to fix

          Format has 33 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Format
          {
          public const
          FIT_TYPE_INNER = 0, // вписать
          FIT_TYPE_OUTER = 1, // описать
          Severity: Minor
          Found in src/Sampler/Format.php - About 4 hrs to fix

            Method convertImagick has 84 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            public function convertImagick(Imagick $imagick, ?array $crop, $format): Imagick
            {
            if (! $format instanceof Sampler\Format) {
            if (! is_array($format)) {
            throw new Sampler\Exception("Unexpected type of format");
            Severity: Major
            Found in src/Sampler.php - About 3 hrs to fix

              The class Sampler has an overall complexity of 128 which is very high. The configured complexity threshold is 50.
              Open

              class Sampler
              {
              /**
              * @throws ImagickException
              */
              Severity: Minor
              Found in src/Sampler.php by phpmd

              The class Storage has an overall complexity of 183 which is very high. The configured complexity threshold is 50.
              Open

              class Storage implements StorageInterface
              {
              private const EXTENSION_DEFAULT = 'jpg';
               
              private const INSERT_MAX_ATTEMPTS = 15;
              Severity: Minor
              Found in src/Storage.php by phpmd

              Function cropImage has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              private function cropImage(Imagick $imagick, array $crop, Sampler\Format $format): Imagick
              {
              $cropSet = isset($crop['width'], $crop['height'], $crop['left'], $crop['top']);
              if (! $cropSet) {
              throw new Sampler\Exception('Crop parameters not properly set');
              Severity: Minor
              Found in src/Sampler.php - About 3 hrs to fix

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

              private function doFormatImage(int $imageId, string $formatName): int
              {
              // find source image
              /** @var ResultSet $resultSet */
              $resultSet = $this->imageTable->select([
              Severity: Minor
              Found in src/Storage.php - About 2 hrs to fix

              Method cropImage has 67 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              private function cropImage(Imagick $imagick, array $crop, Sampler\Format $format): Imagick
              {
              $cropSet = isset($crop['width'], $crop['height'], $crop['left'], $crop['top']);
              if (! $cropSet) {
              throw new Sampler\Exception('Crop parameters not properly set');
              Severity: Major
              Found in src/Sampler.php - About 2 hrs to fix

                Method addImageFromFile has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                public function addImageFromFile(string $file, string $dirName, array $options = []): int
                {
                $imageInfo = getimagesize($file);
                 
                $width = (int) $imageInfo[0];
                Severity: Major
                Found in src/Storage.php - About 2 hrs to fix

                  Method addImageFromImagick has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  public function addImageFromImagick(Imagick $imagick, string $dirName, array $options = []): int
                  {
                  $width = $imagick->getImageWidth();
                  $height = $imagick->getImageHeight();
                   
                   
                  Severity: Major
                  Found in src/Storage.php - About 2 hrs to fix

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

                    private function extendHorizontal(Imagick $imagick, Sampler\Format $format): void
                    {
                    $fRatio = (int) $format->getWidth() / (int) $format->getHeight();
                     
                    $srcWidth = $imagick->getImageWidth();
                    Severity: Minor
                    Found in src/Sampler.php - About 2 hrs to fix

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

                      private function extendVertical(Imagick $imagick, Sampler\Format $format): void
                      {
                      $fRatio = (int) $format->getWidth() / (int) $format->getHeight();
                       
                      $srcWidth = $imagick->getImageWidth();
                      Severity: Minor
                      Found in src/Sampler.php - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language