autowp/image

View on GitHub

Showing 44 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

        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

              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

                        Method changeImageName has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        public function changeImageName(int $imageId, array $options = []): void
                        {
                        $imageRow = $this->getImageRow($imageId);
                        if (! $imageRow) {
                        throw new Storage\Exception("Image `$imageId` not found");
                        Severity: Minor
                        Found in src/Storage.php - About 1 hr to fix

                          Method setImageCrop has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          public function setImageCrop(int $imageId, ?array $crop): void
                          {
                          if (! $imageId) {
                          throw new Storage\Exception("Invalid image id provided `$imageId`");
                          }
                          Severity: Minor
                          Found in src/Storage.php - About 1 hr to fix

                            Method getConsoleConfig has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            public function getConsoleConfig(): array
                            {
                            return [
                            'router' => [
                            'routes' => [
                            Severity: Minor
                            Found in src/ConfigProvider.php - About 1 hr to fix

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

                              public function getImageResolution(int $imageId): ?array
                              {
                              $imageRow = $this->getImageRow($imageId);
                               
                              if (! $imageRow) {
                              Severity: Minor
                              Found in src/Storage.php - About 1 hr to fix

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

                                private function convertByOuterFit(Imagick $imagick, Sampler\Format $format): Imagick
                                {
                                $srcWidth = $imagick->getImageWidth();
                                $srcHeight = $imagick->getImageHeight();
                                $srcRatio = $srcWidth / $srcHeight;
                                Severity: Minor
                                Found in src/Sampler.php - About 1 hr to fix

                                  Method getFormatedImageRows has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  private function getFormatedImageRows(array $imagesId, string $formatName): array
                                  {
                                  $destImageRows = [];
                                  if (count($imagesId)) {
                                  $select = $this->imageTable->getSql()->select()
                                  Severity: Minor
                                  Found in src/Storage.php - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language