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