Passed
Push — master ( 19a915...d9efc8 )
by Gabriel
14:56
created

DuplicatePurchase::fromSibling()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 6
c 1
b 0
f 1
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace ByTIC\Payments\Actions\Purchases;
4
5
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait;
6
use ByTIC\Payments\Models\Purchases\Purchase;
7
8
/**
9
 * Class DuplicatePurchase
10
 * @package ByTIC\Payments\Actions\Purchases
11
 */
12
class DuplicatePurchase
13
{
14
    /**
15
     * @param Purchase|IsPurchasableModelTrait $purchase
16
     * @return Purchase
17
     */
18
    public static function fromSibling($purchase): \Nip\Records\AbstractModels\Record
19
    {
20
        $duplicate = $purchase->getClone();
0 ignored issues
show
Bug introduced by
It seems like getClone() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        /** @scrutinizer ignore-call */ 
21
        $duplicate = $purchase->getClone();
Loading history...
21
        $unset = ['uuid','status'];
22
        foreach ($unset as $field) {
23
            unset($duplicate->{$field});
24
        }
25
        $duplicate->insert();
26
        return $duplicate;
27
    }
28
}