| Conditions | 2 |
| Paths | 2 |
| Total Lines | 69 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 32 | protected function populateConfig(ArrayObject $config) |
||
| 33 | { |
||
| 34 | $config->defaults([ |
||
| 35 | 'payum.factory_name' => self::FACTORY_NAME, |
||
| 36 | 'payum.factory_title' => 'braintree', |
||
| 37 | |||
| 38 | 'payum.http_client' => '@bitbag_sylius_braintree_plugin.api_client.braintree', |
||
| 39 | |||
| 40 | 'payum.template.obtain_payment_method_nonce' => '@BitBagSyliusBraintreePlugin/Action/obtain_payment_method_nonce.html.twig', |
||
| 41 | 'payum.template.obtain_cardholder_authentication' => '@BitBagSyliusBraintreePlugin/Action/obtain_cardholder_authentication.html.twig', |
||
| 42 | |||
| 43 | 'payum.action.capture' => new CaptureAction(), |
||
| 44 | |||
| 45 | 'payum.action.purchase' => function (ArrayObject $config) { |
||
| 46 | $action = new PurchaseAction(); |
||
| 47 | $action->setCardholderAuthenticationRequired($config['cardholderAuthenticationRequired']); |
||
| 48 | |||
| 49 | return $action; |
||
| 50 | }, |
||
| 51 | |||
| 52 | 'payum.action.convert_payment' => new ConvertPaymentAction(), |
||
| 53 | |||
| 54 | 'payum.action.obtain_payment_method_nonce' => function (ArrayObject $config) { |
||
| 55 | $action = new ObtainPaymentMethodNonceAction($config['payum.template.obtain_payment_method_nonce']); |
||
| 56 | $action->setCardholderAuthenticationRequired($config['cardholderAuthenticationRequired']); |
||
| 57 | |||
| 58 | return $action; |
||
| 59 | }, |
||
| 60 | |||
| 61 | 'payum.action.obtain_cardholder_authentication' => function (ArrayObject $config) { |
||
| 62 | return new ObtainCardholderAuthenticationAction($config['payum.template.obtain_cardholder_authentication']); |
||
| 63 | }, |
||
| 64 | |||
| 65 | 'payum.action.status' => new StatusAction(), |
||
| 66 | |||
| 67 | 'payum.action.api.generate_client_token' => new GenerateClientTokenAction(), |
||
| 68 | 'payum.action.api.find_payment_method_nonce' => new FindPaymentMethodNonceAction(), |
||
| 69 | 'payum.action.api.do_sale' => new DoSaleAction(), |
||
| 70 | |||
| 71 | 'cardholderAuthenticationRequired' => true, |
||
| 72 | ]); |
||
| 73 | |||
| 74 | if (false == $config['payum.api']) { |
||
| 75 | $config['payum.default_options'] = [ |
||
| 76 | 'sandbox' => true, |
||
| 77 | 'storeInVault' => null, |
||
| 78 | 'storeInVaultOnSuccess' => null, |
||
| 79 | 'storeShippingAddressInVault' => null, |
||
| 80 | 'addBillingAddressToPaymentMethod' => null, |
||
| 81 | ]; |
||
| 82 | $config->defaults($config['payum.default_options']); |
||
| 83 | $config['payum.required_options'] = []; |
||
| 84 | |||
| 85 | $config['payum.api'] = function (ArrayObject $config) { |
||
| 86 | // $config->validateNotEmpty($config['payum.required_options']); |
||
| 87 | // |
||
| 88 | // return new Api((array) $config, $config['payum.http_client'], $config['httplug.message_factory']); |
||
| 89 | |||
| 90 | /** @var BraintreeApiClientInterface $apiClient */ |
||
| 91 | $apiClient = $config['payum.http_client']; |
||
| 92 | |||
| 93 | $apiClient->initialise((array) $config); |
||
| 94 | |||
| 95 | return $apiClient; |
||
| 96 | }; |
||
| 97 | } |
||
| 98 | |||
| 99 | $config['payum.paths'] = [ |
||
| 100 | 'PayumBraintree' => __DIR__ . '/Resources/views', |
||
| 101 | ]; |
||
| 104 |