Code Duplication    Length = 8-8 lines in 3 locations

src/SilverStripe/Elastica/ElasticaSearcher.php 3 locations

@@ 255-262 (lines=8) @@
252
	 * @return \PaginatedList    SilverStripe DataObjects returned from the search against ElasticSearch
253
	 */
254
	public function search($queryText, $fieldsToSearch = null,  $testMode = false) {
255
		if ($this->locale == null) {
256
			if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
257
				$this->locale = \Translatable::get_current_locale();
258
			} else {
259
				// if no translatable we only have the default locale
260
				$this->locale = \i18n::default_locale();
261
			}
262
		}
263
264
		$qg = new QueryGenerator();
265
		$qg->setQueryText($queryText);
@@ 322-329 (lines=8) @@
319
	 * @param string $queryText
320
	 */
321
	public function autocomplete_search($queryText, $field) {
322
		if ($this->locale == null) {
323
			if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
324
				$this->locale = \Translatable::get_current_locale();
325
			} else {
326
				// if no translatable we only have the default locale
327
				$this->locale = \i18n::default_locale();
328
			}
329
		}
330
331
		$qg = new QueryGenerator();
332
		$qg->setQueryText($queryText);
@@ 385-392 (lines=8) @@
382
			throw new \InvalidArgumentException('Fields cannot be null');
383
		}
384
385
		if ($this->locale == null) {
386
			if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) {
387
				$this->locale = \Translatable::get_current_locale();
388
			} else {
389
				// if no translatable we only have the default locale
390
				$this->locale = \i18n::default_locale();
391
			}
392
		}
393
394
		$weightedFieldsArray = array();
395
		foreach ($fieldsToSearch as $field => $weighting) {