AuthorizeRequest   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 9
dl 0
loc 61
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getReturnUrl() 0 6 2
A setLanguage() 0 9 3
A getData() 0 20 3
A setReturnUrl() 0 3 1
1
<?php
2
namespace Omnipay\Pelecard\Message;
3
/**
4
 * Authorize Request
5
 *
6
 * @method Response send()
7
 */
8
class AuthorizeRequest extends AbstractRequest
9
{
10
    public function getData()
11
    {
12
        $this->validate('amount', 'card');
13
        //$this->getCard()->validate();
14
        $data = parent::getData();
15
        $data['UserKey'] = $this->getTransactionId();
16
        $data['Total'] = $this->getAmountInteger();
17
        $data['Currency'] = $this->getCurrency();
18
        $data['GoodURL'] = $this->getReturnUrl();
19
        $data['ErrorURL'] = $this->getReturnUrl();
20
        $data['CancelURL'] = $this->getCancelUrl();
21
        $data['CardHolderName'] = $this->getCard()->getName();
22
        $data['CustomerAddressField'] = implode(' ',[$this->getCard()->getAddress1(),$this->getCard()->getAddress2()]);
23
        $data['CustomerCityField'] = $this->getCard()->getCity();
24
        $data['CustomerIndexField'] = $this->getCard()->getPostcode();
25
        $data['CustomerCountryField'] = $this->getCard()->getCountry();
26
        $data['EmailField'] = $this->getCard()->getEmail();
27
        if($this->getParameter('Language')) $data['Language'] = $this->getParameter('Language');
28
        if($this->getParameter('QAResultStatus')) $data['QAResultStatus'] = $this->getParameter('QAResultStatus');
29
        return $data;
30
    }
31
    
32
    /**
33
     * Get GoodURL
34
     *
35
     * @return string
36
     */
37
    public function getReturnUrl()
38
    {
39
        if (empty($this->getParameter('returnUrl'))) {
40
            throw new InvalidRequestException('returnUrl must be set.');
0 ignored issues
show
Bug introduced by
The type Omnipay\Pelecard\Message\InvalidRequestException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
41
        }
42
        return $this->getParameter('returnUrl');
43
    }
44
    
45
    /**
46
     * Set GoodURL
47
     *
48
     * @param string $value
49
     */
50
    public function setReturnUrl($value)
51
    {
52
        return $this->setParameter('returnUrl', $value);
53
    }
54
    
55
    /**
56
     * Sets the language code.
57
     *
58
     * @param string $value
59
     */
60
    public function setLanguage($value)
61
    {
62
        if ($value !== null) {
0 ignored issues
show
introduced by
The condition $value !== null is always true.
Loading history...
63
            $value = strtoupper($value);
64
        }
65
        if(!in_array($value, ['HE','EN','RU'])) {
66
            throw new RuntimeException('Unknown language');
0 ignored issues
show
Bug introduced by
The type Omnipay\Pelecard\Message\RuntimeException was not found. Did you mean RuntimeException? If so, make sure to prefix the type with \.
Loading history...
67
        }
68
        return $this->setParameter('Language', $value);
69
    }
70
}
71