Implementation::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 10
cts 10
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 17
nc 1
nop 8
crap 1

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 MGDigital\BusQue;
4
5
use Psr\Log\LoggerInterface;
6
7
final class Implementation
8
{
9
10
    private $queueResolver;
11
    private $commandSerializer;
12
    private $commandIdGenerator;
13
    private $queueDriver;
14
    private $schedulerDriver;
15
    private $clock;
16
    private $commandBusAdapter;
17
    private $logger;
18
19 26
    public function __construct(
20
        QueueResolverInterface $queueResolver,
21
        CommandSerializerInterface $commandSerializer,
22
        CommandIdGeneratorInterface $commandIdGenerator,
23
        QueueDriverInterface $queueDriver,
24
        SchedulerDriverInterface $schedulerDriver,
25
        ClockInterface $clock,
26
        CommandBusAdapterInterface $commandBusAdapter,
27
        LoggerInterface $logger
28
    ) {
29 26
        $this->queueResolver = $queueResolver;
30 26
        $this->commandSerializer = $commandSerializer;
31 26
        $this->commandIdGenerator = $commandIdGenerator;
32 26
        $this->queueDriver = $queueDriver;
33 26
        $this->schedulerDriver = $schedulerDriver;
34 26
        $this->clock = $clock;
35 26
        $this->commandBusAdapter = $commandBusAdapter;
36 26
        $this->logger = $logger;
37 26
    }
38
39 4
    public function getQueueResolver(): QueueResolverInterface
40
    {
41 4
        return $this->queueResolver;
42
    }
43
44 8
    public function getCommandSerializer(): CommandSerializerInterface
45
    {
46 8
        return $this->commandSerializer;
47
    }
48
49 3
    public function getCommandIdGenerator(): CommandIdGeneratorInterface
50
    {
51 3
        return $this->commandIdGenerator;
52
    }
53
54 14
    public function getQueueDriver(): QueueDriverInterface
55
    {
56 14
        return $this->queueDriver;
57
    }
58
59 2
    public function getSchedulerDriver(): SchedulerDriverInterface
60
    {
61 2
        return $this->schedulerDriver;
62
    }
63
64 1
    public function getClock(): ClockInterface
65
    {
66 1
        return $this->clock;
67
    }
68
69 4
    public function getCommandBusAdapter(): CommandBusAdapterInterface
70
    {
71 4
        return $this->commandBusAdapter;
72
    }
73
74 3
    public function getLogger(): LoggerInterface
75
    {
76 3
        return $this->logger;
77
    }
78
}
79