SaleRequestBuilder::build()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 18
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
namespace Paranoia\Builder\NestPay;
3
4
use Paranoia\Common\Serializer\Serializer;
5
use Paranoia\Request\Request;
6
7
class SaleRequestBuilder extends BaseRequestBuilder
8
{
9
    const TRANSACTION_TYPE = 'Auth';
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
        if ($request->getInstallment()) {
25
            $data['Taksit'] = $this->installmentFormatter->format($request->getInstallment());
26
        }
27
28
        $serializer = new Serializer(Serializer::XML);
29
        return $serializer->serialize($data, ['root_name' => self::ENVELOPE_NAME]);
30
    }
31
}
32