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