Completed
Push — master ( 4447aa...e37fbd )
by Vasily
09:14 queued 04:58
created

ExchangeDeclareFrame::create()   F

Complexity

Conditions 9
Paths 256

Size

Total Lines 33
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 20
nc 256
nop 8
dl 0
loc 33
rs 3
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
namespace PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Exchange;
4
5
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\MethodFrame;
6
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\OutgoingFrame;
7
8
/**
9
 * Class ExchangeDeclareFrame
10
 * @author Aleksey I. Kuleshov YOU GLOBAL LIMITED
11
 * @package PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Exchange
12
 */
13
class ExchangeDeclareFrame implements MethodFrame, OutgoingFrame
14
{
15
    const METHOD_ID = 0x0028000a;
16
17
    public $frameChannelId = 0;
18
    public $reserved1 = 0; // short
19
    public $exchange; // shortstr
20
    public $type = 'direct'; // shortstr
21
    public $passive = false; // bit
22
    public $durable = false; // bit
23
    public $autoDelete = false; // bit
24
    public $internal = false; // bit
25
    public $nowait = false; // bit
26
    public $arguments = []; // table
27
28
    public static function create(
29
        $exchange = null, $type = null, $passive = null, $durable = null, $autoDelete = null, $internal = null, $nowait = null, $arguments = null
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 145 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
30
    )
31
    {
32
        $frame = new self();
33
34
        if (null !== $exchange) {
35
            $frame->exchange = $exchange;
36
        }
37
        if (null !== $type) {
38
            $frame->type = $type;
39
        }
40
        if (null !== $passive) {
41
            $frame->passive = $passive;
42
        }
43
        if (null !== $durable) {
44
            $frame->durable = $durable;
45
        }
46
        if (null !== $autoDelete) {
47
            $frame->autoDelete = $autoDelete;
48
        }
49
        if (null !== $internal) {
50
            $frame->internal = $internal;
51
        }
52
        if (null !== $nowait) {
53
            $frame->nowait = $nowait;
54
        }
55
        if (null !== $arguments) {
56
            $frame->arguments = $arguments;
57
        }
58
59
        return $frame;
60
    }
61
}
62