CollectGatewayFactory::populateConfig()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 36
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 27
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 36
ccs 27
cts 27
cp 1
rs 8.8571
cc 2
eloc 24
nc 2
nop 1
crap 2
1
<?php
2
3
namespace PayumTW\Collect;
4
5
use Payum\Core\GatewayFactory;
6
use Payum\Core\Bridge\Spl\ArrayObject;
7
use PayumTW\Collect\Action\CancelAction;
8
use PayumTW\Collect\Action\NotifyAction;
9
use PayumTW\Collect\Action\RefundAction;
10
use PayumTW\Collect\Action\StatusAction;
11
use PayumTW\Collect\Action\CaptureAction;
12
use PayumTW\Collect\Action\NotifyNullAction;
13
use PayumTW\Collect\Action\ConvertPaymentAction;
14
use PayumTW\Collect\Action\Api\CancelTransactionAction;
15
use PayumTW\Collect\Action\Api\CreateTransactionAction;
16
use PayumTW\Collect\Action\Api\RefundTransactionAction;
17
18
class CollectGatewayFactory extends GatewayFactory
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23 1
    protected function populateConfig(ArrayObject $config)
24
    {
25 1
        $config->defaults([
26 1
            'payum.factory_name' => 'collect',
27 1
            'payum.factory_title' => 'Collect',
28
29 1
            'payum.action.capture' => new CaptureAction(),
30 1
            'payum.action.notify' => new NotifyAction(),
31 1
            'payum.action.notify_null' => new NotifyNullAction(),
32 1
            'payum.action.refund' => new RefundAction(),
33 1
            'payum.action.cancel' => new CancelAction(),
34 1
            'payum.action.status' => new StatusAction(),
35 1
            'payum.action.convert_payment' => new ConvertPaymentAction(),
36
37 1
            'payum.action.api.create_transaction' => new CreateTransactionAction(),
38 1
            'payum.action.api.refund_transaction' => new RefundTransactionAction(),
39 1
            'payum.action.api.cancel_transaction' => new CancelTransactionAction(),
40 1
        ]);
41
42 1
        if (false == $config['payum.api']) {
43 1
            $config['payum.default_options'] = [
44 1
                'link_id' => null,
45 1
                'hash_base' => null,
46 1
                'sandbox' => false,
47
            ];
48
49 1
            $config->defaults($config['payum.default_options']);
50 1
            $config['payum.required_options'] = ['link_id', 'hash_base'];
51
52 1
            $config['payum.api'] = function (ArrayObject $config) {
53 1
                $config->validateNotEmpty($config['payum.required_options']);
54
55 1
                return new CollectApi((array) $config, $config['payum.http_client'], $config['httplug.message_factory']);
56
            };
57 1
        }
58 1
    }
59
}
60