Completed
Push — master ( 5ac685...88ad71 )
by Dmitry
13:58
created

TemporaryAction::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 9
dl 0
loc 12
ccs 0
cts 11
cp 0
crap 2
rs 10
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
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2019, HiQDev (http://hiqdev.com/)
9
 */
10
namespace hiqdev\php\billing\action;
11
12
use hiqdev\php\billing\customer\CustomerInterface;
13
14
/**
15
 * Class TemporaryAction represents an action, that is generated for
16
 * runtime-only purposes such as, but not limited to:
17
 *
18
 * - Extending primary action with TemporaryActions, that represent client billing hierarchy
19
 * - Actions produced in ActionMux
20
 *
21
 * Actions of this class MUST NOT be saved into the database and SHOULD be used
22
 * only for runtime calculations.
23
 *
24
 * @author Dmytro Naumenko <[email protected]>
25
 */
26
class TemporaryAction extends Action implements TemporaryActionInterface
27
{
28
    /**
29
     * Creates Temporary Action out of generic $action
30
     *
31
     * @param ActionInterface $action
32
     * @param CustomerInterface $customer
33
     * @return TemporaryAction
34
     */
35
    public static function createAsSubaction(ActionInterface $action, CustomerInterface $customer): TemporaryAction
36
    {
37
        return new self(
38
            null,
39
            $action->getType(),
40
            $action->getTarget(),
41
            $action->getQuantity(),
42
            $customer,
43
            $action->getTime(),
44
            null,
45
            $action->getState(),
46
            $action
47
        );
48
    }
49
}
50