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\Paylike\Message;
4
5
use ByTIC\Omnipay\Paylike\Message\CompletePurchaseRequest as AbstractCompletePurchaseRequest;
6
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Message\Traits\HasGatewayRequestTrait;
7
use ByTIC\Payments\Gateways\Providers\AbstractGateway\Message\Traits\HasModelRequest;
8
use ByTIC\Payments\Gateways\Providers\Paylike\Gateway;
9
use ByTIC\Payments\Models\Purchase\Traits\IsPurchasableModelTrait;
10
11
/**
12
 * Class PurchaseResponse
13
 * @package ByTIC\Payments\Gateways\Providers\Paylike\Message
14
 *
15
 * @method CompletePurchaseResponse send
16
 */
17
class CompletePurchaseRequest extends AbstractCompletePurchaseRequest
18
{
19
    use HasModelRequest;
0 ignored issues
show
introduced by
The trait ByTIC\Payments\Gateways\...\Traits\HasModelRequest requires some properties which are not provided by ByTIC\Payments\Gateways\...CompletePurchaseRequest: $query, $id
Loading history...
20
    use HasGatewayRequestTrait;
21
22
    /**
23
     * @inheritdoc
24
     */
25
    public function getData()
26
    {
27
        $return = parent::getData();
28
        // Add model only if has data
29
        if (count($return) && $this->validateModel()) {
30
            $return['model'] = $this->getModel();
31
        }
32
33
        return $return;
34
    }
35
36
    /**
37
     * @inheritDoc
38
     */
39
    public function getModelIdFromRequest()
40
    {
41
        $modelId = $this->httpRequest->query->get('pOrderId');
42
43
        return $modelId;
44
    }
45
46
    /**
47
     * @return bool|mixed
48
     * @throws \Exception
49
     */
50
    protected function parseNotification()
51
    {
52
        if ($this->validateModel()) {
53
            $model = $this->getModel();
54
            $this->updateParametersFromPurchase($model);
55
        }
56
57
        return parent::parseNotification();
58
    }
59
60
    /**
61
     * @param Gateway $modelGateway
62
     */
63
    protected function updateParametersFromGateway($modelGateway)
64
    {
65
        $this->setPublicKey($modelGateway->getPublicKey());
66
        $this->setPrivateKey($modelGateway->getPrivateKey());
67
    }
68
}
69