| Conditions | 7 | 
| Paths | 24 | 
| Total Lines | 51 | 
| Code Lines | 30 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 3 | ||
| Bugs | 0 | Features | 1 | 
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 | ||
| 68 | public function createManager($managerName, $connection, $analysis, $managerConfig) | ||
| 69 |     { | ||
| 70 |         foreach (array_keys($analysis) as $analyzerType) { | ||
| 71 |             foreach ($connection['analysis'][$analyzerType] as $name) { | ||
| 72 | $connection['settings']['analysis'][$analyzerType][$name] = $analysis[$analyzerType][$name]; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | unset($connection['analysis']); | ||
| 76 | |||
| 77 |         if (!isset($connection['settings']['number_of_replicas'])) { | ||
| 78 | $connection['settings']['number_of_replicas'] = 0; | ||
| 79 | } | ||
| 80 | |||
| 81 |         if (!isset($connection['settings']['number_of_shards'])) { | ||
| 82 | $connection['settings']['number_of_shards'] = 1; | ||
| 83 | } | ||
| 84 | |||
| 85 | $mappings = $this->metadataCollector->getClientMapping($managerConfig['mappings']); | ||
| 86 | |||
| 87 | $client = ClientBuilder::create(); | ||
| 88 | $client->setHosts($connection['hosts']); | ||
| 89 | $client->setTracer($this->tracer); | ||
| 90 | |||
| 91 |         if ($this->logger && $managerConfig['logger']['enabled']) { | ||
| 92 | $client->setLogger($this->logger); | ||
| 93 | } | ||
| 94 | |||
| 95 | $indexSettings = [ | ||
| 96 | 'index' => $connection['index_name'], | ||
| 97 | 'body' => array_filter( | ||
| 98 | [ | ||
| 99 | 'settings' => $connection['settings'], | ||
| 100 | 'mappings' => $mappings, | ||
| 101 | ] | ||
| 102 | ), | ||
| 103 | ]; | ||
| 104 | |||
| 105 | $manager = new Manager( | ||
| 106 | $managerName, | ||
| 107 | $managerConfig, | ||
| 108 | $client->build(), | ||
| 109 | $indexSettings, | ||
| 110 | $this->metadataCollector, | ||
| 111 | $this->converter | ||
| 112 | ); | ||
| 113 | |||
| 114 | $manager->setCommitMode($managerConfig['commit_mode']); | ||
| 115 | $manager->setBulkCommitSize($managerConfig['bulk_size']); | ||
| 116 | |||
| 117 | return $manager; | ||
| 118 | } | ||
| 119 | } | ||
| 120 |