Passed
Push — 12.3.x ( aa7ee0...3ce9e3 )
by Tom
09:04
created

QueryBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
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 8
dl 0
loc 10
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\Event;
6
7
use Doctrine\ORM\QueryBuilder as DoctrineQueryBuilder;
8
use GraphQL\Type\Definition\ResolveInfo;
9
use League\Event\HasEventName;
10
11
/**
12
 * This event is fired when the QueryBuilder is created for an entity
13
 */
14
class QueryBuilder implements
15
    HasEventName
16
{
17
    /** @param mixed[] $args */
18
    public function __construct(
19
        protected readonly string $eventName,
20
        protected readonly DoctrineQueryBuilder $queryBuilder,
21
        protected readonly int $offset,
22
        protected readonly int $limit,
23
        protected readonly mixed $objectValue,
24
        protected readonly array $args,
25
        protected readonly mixed $context,
26
        protected readonly ResolveInfo $info,
27
    ) {
28
    }
29
30
    public function eventName(): string
31
    {
32
        return $this->eventName;
33
    }
34
35
    public function getQueryBuilder(): DoctrineQueryBuilder
36
    {
37
        return $this->queryBuilder;
38
    }
39
40
    public function getOffset(): int
41
    {
42
        return $this->offset;
43
    }
44
45
    public function getLimit(): int
46
    {
47
        return $this->limit;
48
    }
49
50
    public function getObjectValue(): mixed
51
    {
52
        return $this->objectValue;
53
    }
54
55
    /** @return mixed[] */
56
    public function getArgs(): array
57
    {
58
        return $this->args;
59
    }
60
61
    public function getContext(): mixed
62
    {
63
        return $this->context;
64
    }
65
66
    public function getInfo(): ResolveInfo
67
    {
68
        return $this->info;
69
    }
70
}
71