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