Code Duplication    Length = 6-10 lines in 3 locations

src/Services/LDAPService.php 3 locations

@@ 250-259 (lines=10) @@
247
248
        if (!$results || !$cached) {
249
            $results = [];
250
            foreach ($searchLocations as $searchLocation) {
251
                $records = $this->gateway->getGroups($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
252
                if (!$records) {
253
                    continue;
254
                }
255
256
                foreach ($records as $record) {
257
                    $results[$record[$indexBy]] = $record;
258
                }
259
            }
260
261
            $cache->set($cacheKey, $results);
262
        }
@@ 287-292 (lines=6) @@
284
285
        $searchLocations = $this->config()->groups_search_locations ?: [null];
286
        $results = [];
287
        foreach ($searchLocations as $searchLocation) {
288
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
289
            foreach ($records as $record) {
290
                $results[$record['dn']] = $record;
291
            }
292
        }
293
294
        self::$_cache_nested_groups[$dn] = $results;
295
        return $results;
@@ 347-356 (lines=10) @@
344
        $searchLocations = $this->config()->users_search_locations ?: [null];
345
        $results = [];
346
347
        foreach ($searchLocations as $searchLocation) {
348
            $records = $this->gateway->getUsers($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
349
            if (!$records) {
350
                continue;
351
            }
352
353
            foreach ($records as $record) {
354
                $results[$record['objectguid']] = $record;
355
            }
356
        }
357
358
        return $results;
359
    }