BoletoDecorator   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 39
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBoletoFields() 0 10 1
A getSchema() 0 10 2
B beforeConstruct() 0 14 5
1
<?php
2
3
/*
4
 * This file is part of gpupo/adyen-sdk
5
 * Created by Gilmar Pupo <[email protected]>
6
 * For the information of copyright and license you should read the file
7
 * LICENSE which is distributed with this source code.
8
 * Para a informação dos direitos autorais e de licença você deve ler o arquivo
9
 * LICENSE que é distribuído com este código-fonte.
10
 * Para obtener la información de los derechos de autor y la licencia debe leer
11
 * el archivo LICENSE que se distribuye con el código fuente.
12
 * For more information, see <https://opensource.gpupo.com/>.
13
 */
14
15
namespace Gpupo\AdyenSdk\Payment\Response\Decorator;
16
17
use Gpupo\AdyenSdk\Payment\Response\SuccessInterface;
18
19
class BoletoDecorator extends AbstractDecorator implements SuccessInterface
20
{
21 3
    protected function getBoletoFields()
22
    {
23
        return [
24 3
            'barCodeReference',
25
            'data',
26
            'dueDate',
27
            'url',
28
            'expirationDate',
29
        ];
30
    }
31
32 3
    public function getSchema()
33
    {
34 3
        $list = parent::getSchema();
35
36 3
        foreach ($this->getBoletoFields() as $item) {
37 3
            $list[$item] = 'string';
38
        }
39
40 3
        return $list;
41
    }
42
43 3
    protected function beforeConstruct($data = null)
44
    {
45 3
        if (array_key_exists('additionalData', $data) && is_array($data['additionalData'])) {
46 3
            foreach ($this->getBoletoFields() as $item) {
47 3
                $key = 'boletobancario.'.$item;
48 3
                if (array_key_exists($key, $data['additionalData'])) {
49 3
                    $data[$item] = $data['additionalData'][$key];
50 3
                    unset($data['additionalData'][$key]);
51
                }
52
            }
53
        }
54
55 3
        return parent::beforeConstruct($data);
56
    }
57
}
58