HasPurchaseParent   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPurchaseFk() 0 3 1
A populateFromPayment() 0 7 1
1
<?php
2
3
namespace ByTIC\Payments\Models\AbstractModels;
4
5
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait;
6
7
/**
8
 * Trait HasPurchaseParent
9
 * @package ByTIC\Payments\Models\AbstractModels
10
 */
11
trait HasPurchaseParent
12
{
13
    /**
14
     * @param IsPurchasableModelTrait $payment
15
     * @return $this
16
     */
17
    public function populateFromPayment($payment)
18
    {
19
        $this->{$this->getPurchaseFk()} = $payment->id;
20
        $this->amount = floor($payment->getPurchaseAmount() * 100);
0 ignored issues
show
Bug Best Practice introduced by
The property amount does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
        $this->currency = $payment->getPurchaseCurrency();
0 ignored issues
show
Bug Best Practice introduced by
The property currency does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
23
        return $this;
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    protected function getPurchaseFk()
30
    {
31
        return 'id_purchase';
32
    }
33
}
34