Completed
Push — master ( 8ca68a...b0dc5f )
by Hannes
02:09
created

MandateResponseNode::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 17
nc 1
nop 8

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
 * This file is part of byrokrat\autogiro.
4
 *
5
 * byrokrat\autogiro is free software: you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License as published
7
 * by the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * byrokrat\autogiro is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with byrokrat\autogiro. If not, see <http://www.gnu.org/licenses/>.
17
 *
18
 * Copyright 2016 Hannes Forsgård
19
 */
20
21
declare(strict_types = 1);
22
23
namespace byrokrat\autogiro\Tree\Record\Response;
24
25
use byrokrat\autogiro\Tree\Record\RecordNode;
26
use byrokrat\autogiro\Tree\Account\AccountNode;
27
use byrokrat\autogiro\Tree\Account\BankgiroNode;
28
use byrokrat\autogiro\Tree\Date\DateNode;
29
use byrokrat\autogiro\Tree\Id\IdNode;
30
use byrokrat\autogiro\Tree\MessageNode;
31
use byrokrat\autogiro\Tree\PayerNumberNode;
32
33
/**
34
 * Node with data representing a new mandate
35
 */
36
class MandateResponseNode extends RecordNode
37
{
38
    public function __construct(
39
        int $lineNr,
40
        BankgiroNode $bankgiro,
41
        PayerNumberNode $payerNr,
42
        AccountNode $account,
43
        IdNode $id,
44
        MessageNode $info,
45
        MessageNode $comment,
46
        DateNode $date
47
    ) {
48
        parent::__construct($lineNr);
49
        $this->setChild('bankgiro', $bankgiro);
50
        $this->setChild('payer_number', $payerNr);
51
        $this->setChild('account', $account);
52
        $this->setChild('id', $id);
53
        $this->setChild('info', $info);
54
        $this->setChild('comment', $comment);
55
        $this->setChild('date', $date);
56
    }
57
}
58