Completed
Push — master ( 4b8e08...fc2b64 )
by Mike
03:12
created

Implementation::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

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
class Implementation
6
{
7
8
    private $queueNameResolver;
9
    private $commandSerializer;
10
    private $commandIdGenerator;
11
    private $queueAdapter;
12
    private $schedulerAdapter;
13
    private $clock;
14
    private $commandBusAdapter;
15
    private $errorHandler;
16
17
    public function __construct(
18
        QueueNameResolverInterface $queueNameResolver,
19
        CommandSerializerInterface $commandSerializer,
20
        CommandIdGeneratorInterface $commandIdGenerator,
21
        QueueAdapterInterface $queueAdapter,
22
        SchedulerAdapterInterface $schedulerAdapter,
23
        ClockInterface $clock,
24
        CommandBusAdapterInterface $commandBusAdapter,
25
        ErrorHandlerInterface $errorHandler
26
    ) {
27
        $this->queueNameResolver = $queueNameResolver;
28
        $this->commandSerializer = $commandSerializer;
29
        $this->commandIdGenerator = $commandIdGenerator;
30
        $this->queueAdapter = $queueAdapter;
31
        $this->schedulerAdapter = $schedulerAdapter;
32
        $this->clock = $clock;
33
        $this->commandBusAdapter = $commandBusAdapter;
34
        $this->errorHandler = $errorHandler;
35
    }
36
37
    public function getQueueNameResolver(): QueueNameResolverInterface
38
    {
39
        return $this->queueNameResolver;
40
    }
41
42
    public function getCommandSerializer(): CommandSerializerInterface
43
    {
44
        return $this->commandSerializer;
45
    }
46
47
    public function getCommandIdGenerator(): CommandIdGeneratorInterface
48
    {
49
        return $this->commandIdGenerator;
50
    }
51
52
    public function getQueueAdapter(): QueueAdapterInterface
53
    {
54
        return $this->queueAdapter;
55
    }
56
57
    public function getSchedulerAdapter(): SchedulerAdapterInterface
58
    {
59
        return $this->schedulerAdapter;
60
    }
61
62
    public function getClock(): ClockInterface
63
    {
64
        return $this->clock;
65
    }
66
67
    public function getCommandBusAdapter(): CommandBusAdapterInterface
68
    {
69
        return $this->commandBusAdapter;
70
    }
71
72
    public function getErrorHandler(): ErrorHandlerInterface
73
    {
74
        return $this->errorHandler;
75
    }
76
}
77