Passed
Push — master ( ff7474...c002dd )
by Gabriel
05:50
created

updateParametersFromGateway()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
namespace ByTIC\Payments\Gateways\Providers\Euplatesc\Message\Traits;
4
5
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Message\Traits\HasGatewayRequestTrait;
6
use ByTIC\Payments\Gateways\Providers\Euplatesc\Gateway;
7
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait;
8
9
/**
10
 * Trait CompletePurchaseTrait
11
 * @package ByTIC\Payments\Gateways\Providers\Euplatesc\Message\Traits
12
 */
13
trait CompletePurchaseTrait
14
{
15
    use HasGatewayRequestTrait;
16
17
    /**
18
     * @inheritdoc
19
     */
20
    public function getData()
21
    {
22
        $return = parent::getData();
23
        // Add model only if has data
24
        if (count($return)) {
25
            $return['model'] = $this->getModel();
0 ignored issues
show
Bug introduced by
It seems like getModel() 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

25
            /** @scrutinizer ignore-call */ 
26
            $return['model'] = $this->getModel();
Loading history...
26
        }
27
28
        return $return;
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    protected function parseNotification()
35
    {
36
        if ($this->validateModel()) {
0 ignored issues
show
Bug introduced by
It seems like validateModel() 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

36
        if ($this->/** @scrutinizer ignore-call */ validateModel()) {
Loading history...
37
            $model = $this->getModel();
38
            $this->updateParametersFromPurchase($model);
39
        }
40
41
        return parent::parseNotification();
42
    }
43
44
    /**
45
     * @param Gateway $model
46
     */
47
    protected function updateParametersFromGateway($gateway)
48
    {
49
        $this->setMid($gateway->getMid());
0 ignored issues
show
Bug introduced by
It seems like setMid() 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

49
        $this->/** @scrutinizer ignore-call */ 
50
               setMid($gateway->getMid());
Loading history...
50
        $this->setKey($gateway->getKey());
0 ignored issues
show
Bug introduced by
It seems like setKey() 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

50
        $this->/** @scrutinizer ignore-call */ 
51
               setKey($gateway->getKey());
Loading history...
51
    }
52
}
53