Completed
Push — master ( abb491...352f9f )
by Olivier
01:38
created

PaymentIntentCreate::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 68

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 62
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 68
ccs 62
cts 62
cp 1
rs 8.6981
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Shapin\Stripe\Configuration;
11
12
use Shapin\Stripe\Model\PaymentIntent\PaymentIntent;
13
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
14
use Symfony\Component\Config\Definition\ConfigurationInterface;
15
16
class PaymentIntentCreate implements ConfigurationInterface
17
{
18 1
    public function getConfigTreeBuilder()
19
    {
20 1
        $treeBuilder = new TreeBuilder('shapin_stripe');
21 1
        $rootNode = $treeBuilder->getRootNode();
22
23
        $rootNode
24 1
            ->children()
25 1
                ->integerNode('amount')
26 1
                    ->isRequired()
27 1
                    ->info('A positive integer representing how much to charge in the smallest currency unit (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). The minimum amount is $0.50 US or equivalent in charge currency. The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).')
28 1
                ->end()
29 1
                ->scalarNode('currency')
30 1
                    ->isRequired()
31 1
                    ->info('Three-letter ISO currency code, in lowercase. Must be a supported currency.')
32 1
                ->end()
33 1
                ->integerNode('application_fee_amount')
34 1
                    ->info('The amount of the application fee (if any) that will be applied to the payment and transferred to the application owner’s Stripe account. For more information, see the PaymentIntents use case for connected accounts.')
35 1
                ->end()
36 1
                ->enumNode('capture_method')
37 1
                    ->cannotBeEmpty()
38 1
                    ->values([PaymentIntent::CAPTURE_METHOD_MANUAL, PaymentIntent::CAPTURE_METHOD_AUTOMATIC])
39 1
                    ->info('One of automatic (default) or manual. When the capture method is automatic, Stripe automatically captures funds when the customer authorizes the payment. Change capture_method to manual if you wish to separate authorization and capture for payment methods that support this.')
40 1
                ->end()
41 1
                ->booleanNode('confirm')
42 1
                    ->info('Set to true to attempt to confirm this PaymentIntent immediately. This parameter defaults to false. When creating and confirming a PaymentIntent at the same time, parameters available in the confirm API may also be provided.')
43 1
                ->end()
44 1
                ->enumNode('confirmation_method')
45 1
                    ->cannotBeEmpty()
46 1
                    ->values([PaymentIntent::CONFIRMATION_METHOD_MANUAL, PaymentIntent::CONFIRMATION_METHOD_AUTOMATIC])
47 1
                    ->info('One of automatic (default) or manual. When the confirmation method is automatic, a PaymentIntent can be confirmed using a publishable key. After next_actions are handled, no additional confirmation is required to complete the payment. When the confirmation method is manual, all payment attempts must be made using a secret key. The PaymentIntent returns to the requires_confirmation state after handling next_actions, and requires your server to initiate each payment attempt with an explicit confirmation. Learn more about the different confirmation flows.')
48 1
                ->end()
49 1
                ->scalarNode('customer')
50 1
                    ->info('ID of the Customer this PaymentIntent belongs to, if one exists. If present, payment methods used with this PaymentIntent can only be attached to this Customer, and payment methods attached to other Customers cannot be used with this PaymentIntent.')
51 1
                ->end()
52 1
                ->scalarNode('description')
53 1
                    ->info('An arbitrary string attached to the object. Often useful for displaying to users. This can be unset by updating the value to null and then saving.')
54 1
                ->end()
55 1
                ->arrayNode('metadata')
56 1
                    ->scalarPrototype()->end()
57 1
                    ->info('A set of key/value pairs that you can attach to a source object. It can be useful for storing additional information about the source in a structured format.')
58 1
                ->end()
59 1
                ->booleanNode('off_session')
60 1
                    ->info('Set to true to indicate that the customer is not in your checkout flow during this payment attempt, and therefore is unable to authenticate. This parameter is intended for scenarios where you collect card details and charge them later. This parameter can only be used with confirm=true.')
61 1
                ->end()
62 1
                ->scalarNode('on_behalf_of')
63 1
                    ->info('The Stripe account ID for which these funds are intended. For details, see the PaymentIntents use case for connected accounts.')
64 1
                ->end()
65 1
                ->scalarNode('payment_method')
66 1
                    ->info('ID of the payment method (a PaymentMethod, Card, BankAccount, or saved Source object) to attach to this PaymentIntent.')
67 1
                ->end()
68 1
                ->booleanNode('save_payment_method')
69 1
                    ->info('If the PaymentIntent has a payment_method and a customer or if you’re attaching a payment method to the PaymentIntent in this request, you can pass save_payment_method=true to save the payment method to the customer. Defaults to false. If the payment method is already saved to a customer, this does nothing. If this type of payment method cannot be saved to a customer, the request will error.')
70 1
                ->end()
71 1
                ->enumNode('setup_future_usage')
72 1
                    ->values(['on_session', 'off_session'])
73 1
                    ->info('Indicates that you intend to make future payments with this PaymentIntent’s payment method.')
74 1
                ->end()
75 1
                ->scalarNode('statement_descriptor')
76 1
                    ->info('For non-card charges, you can use this value as the complete description that appears on your customers’ statements. Must contain at least one letter, maximum 22 characters.')
77 1
                ->end()
78 1
                ->scalarNode('statement_descriptor_suffix')
79 1
                    ->info('Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that’s set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor.')
80 1
                ->end()
81 1
            ->end()
82
        ;
83
84 1
        return $treeBuilder;
85
    }
86
}
87