Passed
Push — master ( 07d70b...44bdf4 )
by Pablo
09:06
created

AbstractResponse::getAuthorisationCode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 6
c 1
b 1
f 0
nc 2
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Omnipay\Redsys\Message;
6
7
abstract class AbstractResponse extends \Omnipay\Common\Message\AbstractResponse
8
{
9
    /**
10
     * Helper method to get a specific response parameter if available.
11
     *
12
     * @param string $key The key to look up
13
     *
14
     * @return mixed|null
15
     */
16
    abstract protected function getKey($key);
17
18
    /**
19
     * @return string|null
20
     */
21
    protected function getAuthorisationCode()
22
    {
23
        $value = $this->getKey('Ds_AuthorisationCode');
24
25
        $value = str_replace('+', '', $value);
26
        $value = trim($value);
27
28
        if ('' === $value) {
29
            return null;
30
        }
31
32
        return $value;
33
    }
34
}
35