CoverActionData::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 10
dl 0
loc 12
rs 10

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Mostafaznv\Larupload\DTOs;
4
5
use Mostafaznv\Larupload\DTOs\Style\ImageStyle;
6
use Mostafaznv\Larupload\Enums\LaruploadFileType;
7
use Mostafaznv\Larupload\Enums\LaruploadImageLibrary;
8
use Mostafaznv\Larupload\Enums\LaruploadNamingMethod;
9
10
class CoverActionData
11
{
12
    public function __construct(
13
        public readonly string                $disk,
14
        public readonly LaruploadNamingMethod $namingMethod,
15
        public readonly ?string               $lang,
16
        public readonly ImageStyle            $style,
17
        public readonly ?LaruploadFileType    $type,
18
        public readonly bool                  $generateCover,
19
        public readonly bool                  $withDominantColor,
20
        public readonly int                   $dominantColorQuality,
21
        public readonly LaruploadImageLibrary $imageProcessingLibrary,
22
        public array                          $output
23
    ) {}
24
25
    public static function make(string $disk, LaruploadNamingMethod $namingMethod, string $lang, ImageStyle $style, ?LaruploadFileType $type, bool $generateCover, bool $withDominantColor, int $dominantColorQuality, LaruploadImageLibrary $imageProcessingLibrary, array $output): static
26
    {
27
        return new static($disk, $namingMethod, $lang, $style, $type, $generateCover, $withDominantColor, $dominantColorQuality, $imageProcessingLibrary, $output);
28
    }
29
}
30