Passed
Push — master ( ff7474...c002dd )
by Gabriel
05:50
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 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
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\Librapay\Message\Traits;
4
5
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Message\Traits\HasGatewayRequestTrait;
6
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Message\Traits\HasModelRequest;
7
use ByTIC\Payments\Gateways\Providers\Librapay\Gateway;
8
use ByTIC\Payments\Gateways\Providers\Librapay\Helper;
9
10
/**
11
 * Trait CompletePurchaseTrait
12
 */
13
trait CompletePurchaseTrait
14
{
15
    use HasModelRequest;
16
    use HasGatewayRequestTrait;
17
18
    /**
19
     * @inheritdoc
20
     */
21
    public function getData()
22
    {
23
        $return = parent::getData();
24
        // Add model only if has data
25
        if (count($return)) {
26
            $return['model'] = $this->getModel();
27
        }
28
29
        return $return;
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getModelIdFromRequest()
36
    {
37
        $modelId = $this->getHttpRequestBag()->get('ORDER');
0 ignored issues
show
Bug introduced by
The method getHttpRequestBag() does not exist on ByTIC\Payments\Gateways\...s\CompletePurchaseTrait. Did you maybe mean getHttpRequest()? ( Ignorable by Annotation )

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

37
        $modelId = $this->/** @scrutinizer ignore-call */ getHttpRequestBag()->get('ORDER');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        $modelId = Helper::decodeOrderId($modelId);
39
40
        return $modelId;
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    protected function parseNotification()
47
    {
48
        if ($this->validateModel()) {
49
            $model = $this->getModel();
50
            $this->updateParametersFromPurchase($model);
51
        }
52
53
        return parent::parseNotification();
54
    }
55
56
    /**
57
     * @param Gateway $gateway
58
     */
59
    protected function updateParametersFromGateway($gateway)
60
    {
61
        $this->setMerchant($gateway->getMerchant());
0 ignored issues
show
Bug introduced by
It seems like setMerchant() 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

61
        $this->/** @scrutinizer ignore-call */ 
62
               setMerchant($gateway->getMerchant());
Loading history...
62
        $this->setTerminal($gateway->getTerminal());
0 ignored issues
show
Bug introduced by
It seems like setTerminal() 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

62
        $this->/** @scrutinizer ignore-call */ 
63
               setTerminal($gateway->getTerminal());
Loading history...
63
        $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

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

64
        $this->/** @scrutinizer ignore-call */ 
65
               setMerchantName($gateway->getMerchantName());
Loading history...
65
        $this->setMerchantEmail($gateway->getMerchantEmail());
0 ignored issues
show
Bug introduced by
It seems like setMerchantEmail() 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

65
        $this->/** @scrutinizer ignore-call */ 
66
               setMerchantEmail($gateway->getMerchantEmail());
Loading history...
66
        $this->setMerchantUrl($gateway->getMerchantUrl());
0 ignored issues
show
Bug introduced by
It seems like setMerchantUrl() 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

66
        $this->/** @scrutinizer ignore-call */ 
67
               setMerchantUrl($gateway->getMerchantUrl());
Loading history...
67
    }
68
}
69