CancelTrait::getTransactionId()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
ccs 0
cts 0
cp 0
c 0
b 0
f 0
nc 1
1
<?php
2
3
namespace Omnipay\BillPay\Message\RequestData;
4
5
use Omnipay\Common\Exception\InvalidRequestException;
6
use SimpleXMLElement;
7
8
/**
9
 * Class CancelTrait.
10
 *
11
 * @author    Andreas Lange <[email protected]>
12
 * @copyright 2016, Connox GmbH
13
 * @license   MIT
14
 */
15
trait CancelTrait
16
{
17
    /**
18
     * Validates and returns the formated amount.
19
     *
20
     * @throws InvalidRequestException on any validation failure.
21
     *
22
     * @return string The amount formatted to the correct number of decimal places for the selected currency.
23
     *
24
     * @codeCoverageIgnore
25
     */
26
    abstract public function getAmount();
27
28
    /**
29
     * Get the payment currency code.
30
     *
31
     * @return string
32
     *
33
     * @codeCoverageIgnore
34
     */
35
    abstract public function getCurrency();
36
37
    /**
38
     * Get the transaction ID.
39
     *
40
     * The transaction ID is the identifier generated by the merchant website.
41
     *
42
     * @return string
43
     *
44
     * @codeCoverageIgnore
45
     */
46
    abstract public function getTransactionId();
47
48
    /**
49
     * Appends the rate request node to the SimpleXMLElement.
50
     *
51
     * @param SimpleXMLElement $data
52
     *
53
     * @throws InvalidRequestException
54
     */
55 2 View Code Duplication
    protected function appendCancel(SimpleXMLElement $data)
0 ignored issues
show
Duplication introduced by
This method 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...
56
    {
57 2
        $data->addChild('cancel_params');
58 2
        $data->cancel_params[0]['carttotalgross'] = round(bcmul($this->getAmount(), 100, 8));
59 2
        $data->cancel_params[0]['currency'] = $this->getCurrency();
60 2
        $data->cancel_params[0]['reference'] = $this->getTransactionId();
61 2
    }
62
}
63