Conditions | 9 |
Paths | 50 |
Total Lines | 60 |
Code Lines | 37 |
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 |
||
15 | public function load(array $configs, ContainerBuilder $container) |
||
16 | { |
||
17 | $configuration = new Configuration(); |
||
18 | $config = $this->processConfiguration($configuration, $configs); |
||
19 | |||
20 | $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
||
21 | |||
22 | if (isset($config['notifier'])) { |
||
23 | $loader->load('services.xml'); |
||
24 | $container->setParameter('ftrrtf_rollbar.environment.options', $config['environment']); |
||
25 | } |
||
26 | |||
27 | if (isset($config['notifier']['client'])) { |
||
28 | $container->setParameter('ftrrtf_rollbar.notifier.client.options', $config['notifier']['client']); |
||
29 | if (isset($config['notifier']['client']['check_ignore_function_provider'])) { |
||
30 | $container->setParameter( |
||
31 | 'ftrrtf_rollbar.notifier.client.check_ignore_function_provider', |
||
32 | $config['notifier']['client']['check_ignore_function_provider'] |
||
33 | ); |
||
34 | } |
||
35 | |||
36 | if (isset($config['notifier']['client']['transform_payload_function_provider'])) { |
||
37 | $container->setParameter( |
||
38 | 'ftrrtf_rollbar.notifier.client.transform_payload_function_provider', |
||
39 | $config['notifier']['client']['transform_payload_function_provider'] |
||
40 | ); |
||
41 | } |
||
42 | |||
43 | $loader->load('client.xml'); |
||
44 | } |
||
45 | |||
46 | if (isset($config['notifier']['server'])) { |
||
47 | if (isset($config['notifier']['server']['transport']['type'])) { |
||
48 | $transport = $config['notifier']['server']['transport']; |
||
49 | switch ($transport['type']) { |
||
50 | case 'agent': |
||
51 | $container->setParameter( |
||
52 | 'ftrrtf_rollbar.transport.agent_log_location', |
||
53 | $transport['agent_log_location'] |
||
54 | ); |
||
55 | $loader->load('transport_agent.xml'); |
||
56 | $this->prepareLogsDir( |
||
57 | $container->getParameterBag()->resolveValue($transport['agent_log_location']) |
||
58 | ); |
||
59 | |||
60 | break; |
||
61 | case 'curl': |
||
62 | default: |
||
63 | $container->setParameter('ftrrtf_rollbar.transport.access_token', $transport['access_token']); |
||
64 | $loader->load('transport_curl.xml'); |
||
65 | } |
||
66 | |||
67 | unset($config['notifier']['server']['transport']); |
||
68 | } |
||
69 | |||
70 | $container->setParameter('ftrrtf_rollbar.notifier.server.options', $config['notifier']['server']); |
||
71 | |||
72 | $loader->load('server.xml'); |
||
73 | } |
||
74 | } |
||
75 | |||
102 |