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

CompletePurchaseRequest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 50
ccs 0
cts 16
cp 0
rs 10
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getModelIdFromRequest() 0 5 1
A updateParametersFromGateway() 0 4 1
A getData() 0 9 3
A parseNotification() 0 8 2
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