Completed
Push — master ( 5e5795...809938 )
by Olivier
02:11
created

InvoiceList::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 66

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 60
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 66
ccs 60
cts 60
cp 1
rs 8.7418
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\Invoice\Invoice;
13
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
14
use Symfony\Component\Config\Definition\ConfigurationInterface;
15
16
class InvoiceList 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
                ->enumNode('billing')
26 1
                    ->values([Invoice::BILLING_CHARGE_AUTOMATICALLY, Invoice::BILLING_SEND_INVOICE])
27 1
                    ->info('The billing mode of the invoice to retrieve. Either charge_automatically or send_invoice.')
28 1
                ->end()
29 1
                ->scalarNode('customer')
30 1
                    ->info('Only return invoices for the customer specified by this customer ID.')
31 1
                ->end()
32 1
                ->arrayNode('date')
33 1
                    ->children()
34 1
                        ->integerNode('gt')
35 1
                            ->info('Return results where the date field is greater than this value.')
36 1
                        ->end()
37 1
                        ->integerNode('gte')
38 1
                            ->info('Return results where the date field is greater than or equal to this value.')
39 1
                        ->end()
40 1
                        ->integerNode('lt')
41 1
                            ->info('Return results where the date field is less than this value.')
42 1
                        ->end()
43 1
                        ->integerNode('lte')
44 1
                            ->info('Return results where the date field is less than or equal to this value.')
45 1
                        ->end()
46 1
                    ->end()
47 1
                    ->info('A filter on the list based on the object date field. The value can be a string with an integer Unix timestamp, or it can be a dictionary with the following options:')
48 1
                ->end()
49 1
                ->arrayNode('due_date')
50 1
                    ->children()
51 1
                        ->integerNode('gt')
52 1
                            ->info('Return results where the due_date field is greater than this value.')
53 1
                        ->end()
54 1
                        ->integerNode('gte')
55 1
                            ->info('Return results where the due_date field is greater than or equal to this value.')
56 1
                        ->end()
57 1
                        ->integerNode('lt')
58 1
                            ->info('Return results where the due_date field is less than this value.')
59 1
                        ->end()
60 1
                        ->integerNode('lte')
61 1
                            ->info('Return results where the due_date field is less than or equal to this value.')
62 1
                        ->end()
63 1
                    ->end()
64 1
                    ->info('A filter on the list based on the object due_date field. The value can be a string with an integer Unix timestamp, or it can be a dictionary with the following options:')
65 1
                ->end()
66 1
                ->scalarNode('ending_before')
67 1
                    ->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.')
68 1
                ->end()
69 1
                ->integerNode('limit')
70 1
                    ->min(0)->max(100)
71 1
                    ->info('A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.')
72 1
                ->end()
73 1
                ->scalarNode('starting_after')
74 1
                    ->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.')
75 1
                ->end()
76 1
                ->scalarNode('subscription')
77 1
                    ->info('Only return invoices for the subscription specified by this subscription ID.')
78 1
                ->end()
79 1
            ->end()
80
        ;
81
82 1
        return $treeBuilder;
83
    }
84
}
85