Conditions | 29 |
Paths | 1 |
Total Lines | 82 |
Code Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
45 | private function getProvidersNode(): ArrayNodeDefinition |
||
46 | { |
||
47 | $treeBuilder = new TreeBuilder('providers'); |
||
48 | |||
49 | return $this->getRootNode($treeBuilder, 'providers') |
||
50 | ->requiresAtLeastOneElement() |
||
51 | ->useAttributeAsKey('name') |
||
52 | ->variablePrototype() |
||
53 | ->validate() |
||
54 | ->ifEmpty() |
||
55 | ->thenInvalid('Invalid provider configuration %s') |
||
56 | ->end() |
||
57 | ->end() |
||
58 | |||
59 | ->validate() |
||
1 ignored issue
–
show
|
|||
60 | ->always() |
||
61 | ->then(function ($v) { |
||
62 | if (!\array_key_exists('doctrine', $v)) { |
||
63 | $v['doctrine'] = []; |
||
64 | } |
||
65 | |||
66 | // "table_prefix" is empty by default. |
||
67 | if (!\array_key_exists('table_prefix', $v['doctrine']) || !\is_string($v['doctrine']['table_prefix'])) { |
||
68 | $v['doctrine']['table_prefix'] = ''; |
||
69 | } |
||
70 | |||
71 | // "table_suffix" is "_audit" by default. |
||
72 | if (!\array_key_exists('table_suffix', $v['doctrine']) || !\is_string($v['doctrine']['table_suffix'])) { |
||
73 | $v['doctrine']['table_suffix'] = '_audit'; |
||
74 | } |
||
75 | |||
76 | // "entities" are "enabled" by default. |
||
77 | if (\array_key_exists('entities', $v['doctrine']) && \is_array($v['doctrine']['entities'])) { |
||
78 | foreach ($v['doctrine']['entities'] as $entity => $options) { |
||
79 | if (null === $options || !\array_key_exists('enabled', $options)) { |
||
80 | $v['doctrine']['entities'][$entity]['enabled'] = true; |
||
81 | } |
||
82 | } |
||
83 | } |
||
84 | |||
85 | // "doctrine.orm.default_entity_manager" is the default "storage_services" |
||
86 | if (\array_key_exists('storage_services', $v['doctrine']) && \is_string($v['doctrine']['storage_services'])) { |
||
87 | $v['doctrine']['storage_services'] = [$v['doctrine']['storage_services']]; |
||
88 | } elseif (!\array_key_exists('storage_services', $v['doctrine']) || !\is_array($v['doctrine']['storage_services'])) { |
||
89 | $v['doctrine']['storage_services'] = ['doctrine.orm.default_entity_manager']; |
||
90 | } |
||
91 | |||
92 | // "doctrine.orm.default_entity_manager" is the default "auditing_services" |
||
93 | if (\array_key_exists('auditing_services', $v['doctrine']) && \is_string($v['doctrine']['auditing_services'])) { |
||
94 | $v['doctrine']['auditing_services'] = [$v['doctrine']['auditing_services']]; |
||
95 | } elseif (!\array_key_exists('storage_services', $v['doctrine']) || !\is_array($v['doctrine']['auditing_services'])) { |
||
96 | $v['doctrine']['auditing_services'] = ['doctrine.orm.default_entity_manager']; |
||
97 | } |
||
98 | |||
99 | // "storage_mapper" is null by default |
||
100 | if (!\array_key_exists('storage_mapper', $v['doctrine']) || !\is_string($v['doctrine']['storage_mapper'])) { |
||
101 | $v['doctrine']['storage_mapper'] = null; |
||
102 | } |
||
103 | |||
104 | // "roles_checker" is null by default |
||
105 | if (!\array_key_exists('roles_checker', $v['doctrine']) || !\is_string($v['doctrine']['roles_checker'])) { |
||
106 | $v['doctrine']['roles_checker'] = null; |
||
107 | } |
||
108 | |||
109 | // "user_provider" is null by default |
||
110 | if (!\array_key_exists('user_provider', $v['doctrine']) || !\is_string($v['doctrine']['user_provider'])) { |
||
111 | $v['doctrine']['user_provider'] = null; |
||
112 | } |
||
113 | |||
114 | // "security_provider" is null by default |
||
115 | if (!\array_key_exists('security_provider', $v['doctrine']) || !\is_string($v['doctrine']['security_provider'])) { |
||
116 | $v['doctrine']['security_provider'] = null; |
||
117 | } |
||
118 | |||
119 | // "viewer" is enabled by default |
||
120 | if (!\array_key_exists('viewer', $v['doctrine']) || !\is_bool($v['doctrine']['viewer'])) { |
||
121 | $v['doctrine']['viewer'] = true; |
||
122 | } |
||
123 | |||
124 | return $v; |
||
125 | }) |
||
126 | ->end() |
||
127 | ; |
||
130 |