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

CompletePurchaseRequestTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parseNotification() 0 8 2
A updateParametersFromGateway() 0 5 1
1
<?php
2
3
namespace ByTIC\Payments\Gateways\Providers\Mobilpay\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\Mobilpay\Gateway;
8
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait;
9
10
/**
11
 * Trait CompletePurchaseRequestTrait
12
 * @package ByTIC\Payments\Gateways\Providers\Mobilpay\Message\Traits
13
 */
14
trait CompletePurchaseRequestTrait
15
{
16
    use HasGatewayRequestTrait;
17
    use HasModelRequest;
18
19
20
    /**
21
     * @return bool|mixed
22
     * @throws \Exception
23
     */
24 4
    protected function parseNotification()
25
    {
26 4
        if ($this->validateModel()) {
27 4
            $model = $this->getModel();
28 4
            $this->updateParametersFromPurchase($model);
29
        }
30
31 4
        return parent::parseNotification();
32
    }
33
34
    /**
35
     * @param Gateway $modelGateway
36
     */
37 4
    protected function updateParametersFromGateway($modelGateway)
38
    {
39 4
        $this->setSignature($modelGateway->getSignature());
0 ignored issues
show
Bug introduced by
It seems like setSignature() 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

39
        $this->/** @scrutinizer ignore-call */ 
40
               setSignature($modelGateway->getSignature());
Loading history...
40 4
        $this->setCertificate($modelGateway->getCertificate());
0 ignored issues
show
Bug introduced by
It seems like setCertificate() 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

40
        $this->/** @scrutinizer ignore-call */ 
41
               setCertificate($modelGateway->getCertificate());
Loading history...
41 4
        $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

41
        $this->/** @scrutinizer ignore-call */ 
42
               setPrivateKey($modelGateway->getPrivateKey());
Loading history...
42
    }
43
}