TemporaryAction::createAsSubaction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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