CompletePurchaseRequest::getData()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 9
ccs 0
cts 4
cp 0
crap 12
rs 10
1
<?php
2
3
namespace ByTIC\Payments\Gateways\Providers\Paylike\Message;
4
5
use Paytic\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
10
/**
11
 * Class PurchaseResponse
12
 * @package ByTIC\Payments\Gateways\Providers\Paylike\Message
13
 *
14
 * @method CompletePurchaseResponse send
15
 */
16
class CompletePurchaseRequest extends AbstractCompletePurchaseRequest
17
{
18
    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...
19
    use HasGatewayRequestTrait;
20
21
    /**
22
     * @inheritdoc
23
     */
24
    public function getData()
25
    {
26
        $return = parent::getData();
27
        // Add model only if has data
28
        if (count($return) && $this->validateModel()) {
29
            $return['model'] = $this->getModel();
30
        }
31
32
        return $return;
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public function getModelIdFromRequest()
39
    {
40
        $modelId = $this->httpRequest->query->get('pOrderId');
41
42
        return $modelId;
43
    }
44
45
    /**
46
     * @return bool|mixed
47
     * @throws \Exception
48
     */
49
    protected function parseNotification()
50
    {
51
        if ($this->validateModel()) {
52
            $model = $this->getModel();
53
            $this->updateParametersFromPurchase($model);
54
        }
55
56
        return parent::parseNotification();
57
    }
58
59
    /**
60
     * @param Gateway $modelGateway
61
     */
62
    protected function updateParametersFromGateway($modelGateway)
63
    {
64
        $this->setPublicKey($modelGateway->getPublicKey());
65
        $this->setPrivateKey($modelGateway->getPrivateKey());
66
    }
67
}
68