Association::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

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

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
declare(strict_types=1);
4
5
namespace ApiSkeletons\Doctrine\ORM\GraphQL\Attribute;
6
7
use ApiSkeletons\Doctrine\ORM\GraphQL\Filter\Filters;
8
use Attribute;
9
10
/**
11
 * Attribute to describe an association for GraphQL
12
 */
13
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)]
14
final class Association
15
{
16
    use ExcludeFilters;
0 ignored issues
show
Bug introduced by
The trait ApiSkeletons\Doctrine\OR...ttribute\ExcludeFilters requires the property $value which is not provided by ApiSkeletons\Doctrine\OR...L\Attribute\Association.
Loading history...
17
18
    /**
19
     * @param Filters[] $excludeFilters
20
     * @param Filters[] $includeFilters
21
     */
22
    public function __construct(
23
        private readonly string $group = 'default',
24
        private readonly string|null $alias = null,
25
        private readonly string|null $description = null,
26
        private readonly int|null $limit = null,
27
        private readonly string|null $criteriaEventName = null,
28
        private readonly string|null $hydratorStrategy = null,
29
        private readonly array $excludeFilters = [],
30
        private readonly array $includeFilters = [],
31
    ) {
32
    }
33
34
    public function getAlias(): string|null
35
    {
36
        return $this->alias;
37
    }
38
39
    public function getLimit(): int|null
40
    {
41
        return $this->limit;
42
    }
43
44
    public function getGroup(): string
45
    {
46
        return $this->group;
47
    }
48
49
    public function getHydratorStrategy(): string|null
50
    {
51
        return $this->hydratorStrategy;
52
    }
53
54
    public function getDescription(): string|null
55
    {
56
        return $this->description;
57
    }
58
59
    public function getCriteriaEventName(): string|null
60
    {
61
        return $this->criteriaEventName;
62
    }
63
}
64