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

TemporaryAction   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 21
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A createAsSubaction() 0 12 1
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