Completed
Push — master ( 69d984...0eb511 )
by Claude
03:26
created

WebAuthorizeRequest::getData()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 27
Code Lines 17

Duplication

Lines 27
Ratio 100 %

Code Coverage

Tests 20
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 27
loc 27
ccs 20
cts 20
cp 1
rs 8.8571
nc 2
cc 2
eloc 17
nop 0
crap 2
1
<?php
2
3
namespace Omnipay\Payline\Message;
4
/**
5
 * Authorize Request
6
 *
7
 * @method WebAuthorizeResponse send()
8
 */
9 View Code Duplication
class WebAuthorizeRequest extends AbstractRequest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @return boolean
13
     */
14 6
    public function getMethod()
15
    {
16 6
        return 'doWebPayment';
17
    }
18
19 3
    public function getData()
20
    {
21 3
        $data['payment'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
22 3
            'amount' => $this->getAmountInteger(),
23 3
            'currency' => $this->getCurrencyNumeric(),
24 3
            'action' => 100,
25 3
            'mode' => 'CPT',
26
        ];
27
28 3
        if($this->getContractNumber())
29 2
        {
30 3
            $data['payment']['contractNumber'] = $this->getContractNumber();
31 2
        }
32
33 3
        $data['order'] = [
34 3
            'ref' => $this->getTransactionReference(),
35 3
            'amount' => $this->getAmountInteger(),
36 3
            'currency' => $this->getCurrencyNumeric(),
37 3
            'date' => (new \DateTime())->format('d/m/Y H:i')
38 2
        ];
39
40 3
        $data['returnURL'] = $this->getReturnUrl();
41 3
        $data['cancelURL'] = $this->getCancelUrl();
42 3
        $data['notificationURL'] = $this->getNotifyUrl();
43
44 3
        return array_replace_recursive($this->getBaseData(), $data);
45
    }
46
47
    /**
48
     * @param \stdClass $data
49
     * @return WebAuthorizeResponse
50
     */
51 3
    protected function createResponse($data)
52
    {
53 3
        return $this->response = new WebAuthorizeResponse($this, $data);
54
    }
55
}
56