Conditions | 3 |
Paths | 1 |
Total Lines | 63 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
37 | private function configureEntityProto(ArrayNodeDefinition $parent) |
||
38 | { |
||
39 | $parent |
||
40 | ->children() |
||
41 | ->scalarNode('class') |
||
42 | ->isRequired() |
||
43 | ->info('Doctrine class') |
||
44 | ->example('MyBundle:MyEntity'); |
||
45 | |||
46 | $parent |
||
47 | ->children() |
||
48 | ->scalarNode('prefix') |
||
49 | ->defaultNull() |
||
50 | ->info('Route prefix. Defaults to entity key if not set') |
||
51 | ->example('/my-entity'); |
||
52 | |||
53 | $parent |
||
54 | ->children() |
||
55 | ->scalarNode('repository') |
||
56 | ->defaultNull() |
||
57 | ->info('Entity repository. service reference, default to factory-acquired doctrine repository') |
||
58 | ->example('@my_entity.repository'); |
||
59 | |||
60 | |||
61 | $actions = $parent |
||
62 | ->children() |
||
63 | ->arrayNode('actions'); |
||
64 | |||
65 | $actions |
||
66 | ->beforeNormalization() |
||
67 | ->ifArray() |
||
68 | ->then( |
||
69 | function (array $v) { |
||
70 | if (array_keys($v) !== range(0, count($v) - 1)) { |
||
71 | return $v; |
||
72 | } |
||
73 | |||
74 | $result = []; |
||
75 | foreach ($v as $key) { |
||
76 | $result[$key] = ['enabled' => true]; |
||
77 | } |
||
78 | |||
79 | return $result; |
||
80 | } |
||
81 | ) |
||
82 | ->end() |
||
83 | ->info('Action configuration') |
||
84 | ->example( |
||
85 | [ |
||
86 | 'create' => ['enabled' => false], |
||
87 | 'read' => null, |
||
88 | 'update' => null, |
||
89 | 'delete' => ['enabled' => true, 'path' => '/remove'], |
||
90 | 'search' => null, |
||
91 | ] |
||
92 | ); |
||
93 | |||
94 | $this->configureCreateAction($actions); |
||
95 | $this->configureReadAction($actions); |
||
96 | $this->configureUpdateAction($actions); |
||
97 | $this->configureDeleteAction($actions); |
||
98 | $this->configureSearchAction($actions); |
||
99 | } |
||
100 | |||
209 |