Passed
Push — master ( c0f464...9c6e80 )
by Gabriel
11:21
created

HasPurchaseParent   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A populateFromPayment() 0 5 1
A getPurchaseFk() 0 3 1
1
<?php
2
3
namespace ByTIC\Payments\Models\AbstractModels;
4
5
use ByTIC\Payments\Models\Transactions\TransactionTrait;
6
7
/**
8
 * Trait HasPurchaseParent
9
 * @package ByTIC\Payments\Models\AbstractModels
10
 */
11
trait HasPurchaseParent
12
{
13
    /**
14
     * @param $payment
15
     * @return $this
16
     */
17
    public function populateFromPayment($payment)
18
    {
19
        $this->{$this->getPurchaseFk()} = $payment->id;
20
21
        return $this;
22
    }
23
24
    /**
25
     * @return string
26
     */
27
    protected function getPurchaseFk()
28
    {
29
        return 'id_purchase';
30
    }
31
}