PreAuthorizationRequestBuilder::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 14
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace Paranoia\Builder\NestPay;
3
4
use Paranoia\Common\Serializer\Serializer;
5
use Paranoia\Request\Request;
6
7
class PreAuthorizationRequestBuilder extends BaseRequestBuilder
8
{
9
    const TRANSACTION_TYPE = 'PreAuth';
10
    const ENVELOPE_NAME    = 'CC5Request';
11
12
    public function build(Request $request)
13
    {
14
        $data = array_merge(
15
            $this->buildBaseRequest(self::TRANSACTION_TYPE),
16
            [
17
                'OrderId'  => $request->getOrderId(),
18
                'Total'    => $this->amountFormatter->format($request->getAmount()),
19
                'Currency' => $this->currencyCodeFormatter->format($request->getCurrency()),
20
            ],
21
            $this->buildCard($request->getResource())
22
        );
23
24
        $serializer = new Serializer(Serializer::XML);
25
        return $serializer->serialize($data, ['root_name' => self::ENVELOPE_NAME]);
26
    }
27
}
28