Passed
Push — master ( 231fe1...5105bf )
by Gabriel
05:58
created

CompletePurchaseTrait::getData()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 4
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 9
ccs 0
cts 5
cp 0
crap 6
rs 10
1
<?php
2
3
namespace ByTIC\Payments\Gateways\Providers\PlatiOnline\Message\Traits;
4
5
use ByTIC\Payments\Gateways\Providers\Librapay\Gateway;
6
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait;
7
8
/**
9
 * Trait CompletePurchaseTrait
10
 * @package ByTIC\Payments\Gateways\Providers\PlatiOnline\Message\Traits
11
 */
12
trait CompletePurchaseTrait
13
{
14
15
    /**
16
     * @inheritdoc
17
     */
18
    public function getData()
19
    {
20
        $return = parent::getData();
21
        // Add model only if has data
22
        if (count($return)) {
23
            $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

23
            /** @scrutinizer ignore-call */ 
24
            $return['model'] = $this->getModel();
Loading history...
24
        }
25
26
        return $return;
27
    }
28
29
    /**
30
     * @return bool|mixed
31
     * @throws \Exception
32
     */
33
    protected function parseNotification()
34
    {
35
        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

35
        if ($this->/** @scrutinizer ignore-call */ validateModel()) {
Loading history...
36
            $model = $this->getModel();
37
            $this->updateParametersFromModel($model);
38
        }
39
40
        return parent::parseNotification();
41
    }
42
43
    /**
44
     * @param IsPurchasableModelTrait $model
45
     *
46
     * @throws \Exception
47
     */
48
    protected function updateParametersFromModel($model)
49
    {
50
        /** @var \ByTIC\Payments\Gateways\Providers\PlatiOnline\Gateway $modelGateway */
51
        $modelGateway = $model->getPaymentMethod()->getType()->getGateway();
0 ignored issues
show
Bug introduced by
The method getGateway() does not exist on ByTIC\Payments\Models\Methods\Types\AbstractType. It seems like you code against a sub-type of ByTIC\Payments\Models\Methods\Types\AbstractType such as ByTIC\Payments\Models\Methods\Types\CreditCards. ( Ignorable by Annotation )

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

51
        $modelGateway = $model->getPaymentMethod()->getType()->/** @scrutinizer ignore-call */ getGateway();
Loading history...
52
        $this->setPrivateKey($modelGateway->getPrivateKey());
0 ignored issues
show
Bug introduced by
It seems like setPrivateKey() 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

52
        $this->/** @scrutinizer ignore-call */ 
53
               setPrivateKey($modelGateway->getPrivateKey());
Loading history...
53
        $this->setInitialVectorItsn($modelGateway->getInitialVectorItsn());
0 ignored issues
show
Bug introduced by
It seems like setInitialVectorItsn() 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

53
        $this->/** @scrutinizer ignore-call */ 
54
               setInitialVectorItsn($modelGateway->getInitialVectorItsn());
Loading history...
54
    }
55
}
56