CompletePurchaseRequestTrait::parseNotification()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 9.6666
cc 2
eloc 6
nc 2
nop 0
crap 6
1
<?php
2
3
namespace ByTIC\Omnipay\Twispay\Message\Traits;
4
5
use ByTIC\Omnipay\Common\Message\Traits\GatewayNotificationRequestTrait;
6
use ByTIC\Omnipay\Twispay\Helper;
7
8
/**
9
 * Trait CompletePurchaseRequestTrait
10
 * @package ByTIC\Omnipay\Twispay\Message\Traits
11
 */
12
trait CompletePurchaseRequestTrait
13
{
14
    use GatewayNotificationRequestTrait;
15
16
    /**
17
     * @return bool|mixed
18
     */
19
    protected function parseNotification()
20
    {
21
        $dataResult = $this->hasPOST('opensslResult')
22
            ? $this->httpRequest->request->get('opensslResult')
23
            : $this->httpRequest->request->get('result');
24
25
        $json = Helper::decrypt($dataResult, $this->getApiKey());
0 ignored issues
show
Bug introduced by
It seems like getApiKey() 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

25
        $json = Helper::decrypt($dataResult, $this->/** @scrutinizer ignore-call */ getApiKey());
Loading history...
26
        $data = json_decode($json, true);
27
        return $data;
28
    }
29
30
    /**
31
     * @return mixed
32
     */
33
    protected function isValidNotification()
34
    {
35
        return $this->hasGet('id') && ($this->hasPOST('opensslResult') || $this->hasPOST('result'));
36
    }
37
}
38