TemporaryAction   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 17
ccs 0
cts 12
cp 0
rs 10
c 1
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-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