AuthorizeRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 2
dl 0
loc 41
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 33 4
A createResponse() 0 4 1
1
<?php
2
3
namespace Omnipay\Sofort\Message;
4
5
use SimpleXMLElement;
6
7
class AuthorizeRequest extends AbstractRequest
8
{
9
    public function getData()
10
    {
11
        $data = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><multipay/>');
12
13
        $data->addChild('project_id', $this->getProjectId());
14
        $data->addChild('amount', $this->getAmount());
15
        $data->addChild('currency_code', $this->getCurrency());
16
        $data->addChild('test', $this->getTestMode());
17
        $data->addChild('success_url', str_replace('&', '&amp;', $this->getReturnUrl()));
18
        $data->addChild('abort_url', str_replace('&', '&amp;', $this->getCancelUrl()));
19
        $data->addChild('notification_urls')->addChild(
20
            'notification_url',
21
            str_replace('&', '&amp;', $this->getNotifyUrl())
22
        );
23
24
        $reasons = $data->addChild('reasons');
25
26
        if (is_string($this->getDescription())) {
27
            $reasons->addChild('reason', $this->getDescription());
28
        } elseif (is_array($this->getDescription())) {
29
            foreach ($this->getDescription() as $reason) {
30
                $reasons->addChild('reason', $reason);
31
            }
32
        }
33
34
        $su = $data->addChild('su');
35
        $su->addChild('customer_protection', (int) (bool) $this->getProtection());
36
37
        $sender = $data->addChild('sender');
38
        $sender->addChild('country_code', $this->getCountry());
39
40
        return $data;
41
    }
42
43
    protected function createResponse($response)
44
    {
45
        return $this->response = new AuthorizeResponse($this, $response);
46
    }
47
}
48