ChargeList::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 54
ccs 0
cts 52
cp 0
rs 9.0036
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2

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 Symfony\Component\Config\Definition\Builder\TreeBuilder;
13
use Symfony\Component\Config\Definition\ConfigurationInterface;
14
15
class ChargeList implements ConfigurationInterface
16
{
17
    public function getConfigTreeBuilder()
18
    {
19
        $treeBuilder = new TreeBuilder('shapin_stripe');
20
        $rootNode = $treeBuilder->getRootNode();
21
22
        $rootNode
23
            ->children()
24
                ->arrayNode('created')
25
                    ->children()
26
                        ->integerNode('gt')
27
                            ->info('Return results where the created field is greater than this value.')
28
                        ->end()
29
                        ->integerNode('gte')
30
                            ->info('Return results where the created field is greater than or equal to this value.')
31
                        ->end()
32
                        ->integerNode('lt')
33
                            ->info('Return results where the created field is less than this value.')
34
                        ->end()
35
                        ->integerNode('lte')
36
                            ->info('Return results where the created field is less than or equal to this value.')
37
                        ->end()
38
                    ->end()
39
                    ->info('A filter on the list based on the object created field. The value can be a string with an integer Unix timestamp, or it can be a dictionary with the following options:')
40
                ->end()
41
                ->scalarNode('customer')
42
                    ->info('Only return charges for the customer specified by this customer ID.')
43
                ->end()
44
                ->scalarNode('ending_before')
45
                    ->info('A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_bar, your subsequent call can include ending_before=obj_bar in order to fetch the previous page of the list.')
46
                ->end()
47
                ->integerNode('limit')
48
                    ->min(0)->max(100)
49
                    ->info('A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.')
50
                ->end()
51
                ->arrayNode('source')
52
                    ->children()
53
                        ->enumNode('object')
54
                            ->values(['all', 'alipay_account', 'bank_account', 'bitcoin_receiver', 'card'])
55
                            ->info('Return charges that match this source type string. Available options are all, alipay_account, bank_account, bitcoin_receiver, or card.')
56
                        ->end()
57
                    ->end()
58
                    ->info('A filter on the list, based on the source of the charge. The value can be a dictionary with the following options:')
59
                ->end()
60
                ->scalarNode('starting_after')
61
                    ->info('A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include starting_after=obj_foo in order to fetch the next page of the list.')
62
                ->end()
63
                ->scalarNode('transfer_group')
64
                    ->info('Only return charges for this transfer group.')
65
                ->end()
66
            ->end()
67
        ;
68
69
        return $treeBuilder;
70
    }
71
}
72