| Conditions | 5 |
| Paths | 9 |
| Total Lines | 53 |
| Code Lines | 35 |
| 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 |
||
| 97 | if (empty($this->metadataDrivers)) { |
||
| 98 | throw new \InvalidArgumentException( |
||
| 99 | 'You must add at least one metadata driver (e.g. ->addArrayDriver, ->addAnnotationDriver, ->addXmlDriver)' |
||
| 100 | ); |
||
| 101 | } |
||
| 102 | |||
| 103 | $actionRegistry = new ActionRegistry(); |
||
| 104 | foreach ($this->actions as $alias => $action) { |
||
| 105 | $actionRegistry->register($action, $alias); |
||
| 106 | } |
||
| 107 | $columnRegistry = new ColumnRegistry(); |
||
| 108 | foreach ($this->columns as $alias => $column) { |
||
| 109 | $columnRegistry->register($column, $alias); |
||
| 110 | } |
||
| 111 | $filterRegistry = new FilterRegistry(); |
||
| 112 | foreach ($this->filters as $alias => $filter) { |
||
| 113 | $filterRegistry->register($filter, $alias); |
||
| 114 | } |
||
| 115 | |||
| 116 | $metadataDriver = new DriverChain($this->metadataDrivers); |
||
| 117 | $columnFactory = new ColumnFactory($columnRegistry); |
||
| 118 | $metadataFactory = new MetadataFactory($metadataDriver); |
||
| 119 | |||
| 120 | $validator = Validation::createValidator(); |
||
| 121 | |||
| 122 | $formFactory = $this->formFactoryBuilder |
||
| 123 | ->addExtension(new ValidatorExtension($validator)) |
||
| 124 | ->addExtension(new GridExtension( |
||
| 125 | $columnRegistry, |
||
| 126 | $filterRegistry |
||
| 127 | )) |
||
| 128 | ->getFormFactory(); |
||
| 129 | |||
| 130 | $filterFactory = new FilterBarFactory($formFactory, $filterRegistry); |
||
| 131 | $queryFactory = new QueryFactory($metadataFactory); |
||
| 132 | |||
| 133 | $gridViewFactory = new GridViewFactory( |
||
| 134 | $columnFactory, |
||
| 135 | $filterFactory, |
||
| 136 | $queryFactory |
||
| 137 | ); |
||
| 138 | |||
| 139 | $actionPerformer = new ActionPerformer($actionRegistry); |
||
| 140 | |||
| 141 | return new GridFactory( |
||
| 142 | $this->agentFinder, |
||
| 143 | $metadataFactory, |
||
| 144 | $gridViewFactory, |
||
| 145 | $actionPerformer |
||
| 146 | ); |
||
| 147 | } |
||
| 148 | } |
||
| 149 |