Przelewy24GatewayFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A populateConfig() 0 33 2
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusPrzelewy24Plugin;
14
15
use BitBag\SyliusPrzelewy24Plugin\Bridge\Przelewy24BridgeInterface;
16
use Payum\Core\Bridge\Spl\ArrayObject;
17
use Payum\Core\GatewayFactory;
18
19
final class Przelewy24GatewayFactory extends GatewayFactory
20
{
21
    protected function populateConfig(ArrayObject $config): void
22
    {
23
        $config->defaults([
24
            'payum.factory_name' => 'przelewy24',
25
            'payum.factory_title' => 'Przelewy24',
26
        ]);
27
28
        if (false === (bool) $config['payum.api']) {
29
            $config['payum.default_options'] = [
30
                'crc_key' => null,
31
                'merchant_id' => null,
32
                'environment' => Przelewy24BridgeInterface::SANDBOX_ENVIRONMENT,
33
            ];
34
35
            $config->defaults($config['payum.default_options']);
36
37
            $config['payum.required_options'] = [
38
                'crc_key',
39
                'merchant_id',
40
            ];
41
42
            $config['payum.api'] = function (ArrayObject $config) {
43
                $config->validateNotEmpty($config['payum.required_options']);
44
45
                return [
46
                    'crc_key' => $config['crc_key'],
47
                    'merchant_id' => $config['merchant_id'],
48
                    'environment' => $config['environment'],
49
                    'payum.http_client' => $config['payum.http_client'],
50
                ];
51
            };
52
        }
53
    }
54
}
55