Passed
Pull Request — 10.1.x (#99)
by Tom
02:27
created

Association::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 8
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
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
class Association
15
{
16
    use ExcludeFilters;
17
18
    /**
19
     * @param Filters[] $excludeFilters
20
     * @param Filters[] $includeFilters
21
     */
22
    public function __construct(
23
        protected string $group = 'default',
24
        protected string|null $alias = null,
25
        protected string|null $description = null,
26
        protected int|null $limit = null,
27
        protected string|null $criteriaEventName = null,
28
        protected string|null $hydratorStrategy = null,
29
        array $excludeFilters = [],
30
        array $includeFilters = [],
31
    ) {
32
        $this->includeFilters = $includeFilters;
33
        $this->excludeFilters = $excludeFilters;
34
    }
35
36
    public function getAlias(): string|null
37
    {
38
        return $this->alias;
39
    }
40
41
    public function getLimit(): int|null
42
    {
43
        return $this->limit;
44
    }
45
46
    public function getGroup(): string
47
    {
48
        return $this->group;
49
    }
50
51
    public function getHydratorStrategy(): string|null
52
    {
53
        return $this->hydratorStrategy;
54
    }
55
56
    public function getDescription(): string|null
57
    {
58
        return $this->description;
59
    }
60
61
    public function getCriteriaEventName(): string|null
62
    {
63
        return $this->criteriaEventName;
64
    }
65
}
66