Code Duplication    Length = 6-10 lines in 3 locations

src/Services/LDAPService.php 3 locations

@@ 262-271 (lines=10) @@
259
260
        if (!$results || !$cached) {
261
            $results = [];
262
            foreach ($searchLocations as $searchLocation) {
263
                $records = $this->gateway->getGroups($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
264
                if (!$records) {
265
                    continue;
266
                }
267
268
                foreach ($records as $record) {
269
                    $results[$record[$indexBy]] = $record;
270
                }
271
            }
272
273
            $cache->set($cacheKey, $results);
274
        }
@@ 299-304 (lines=6) @@
296
297
        $searchLocations = $this->config()->groups_search_locations ?: [null];
298
        $results = [];
299
        foreach ($searchLocations as $searchLocation) {
300
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
301
            foreach ($records as $record) {
302
                $results[$record['dn']] = $record;
303
            }
304
        }
305
306
        self::$_cache_nested_groups[$dn] = $results;
307
        return $results;
@@ 359-368 (lines=10) @@
356
        $searchLocations = $this->config()->users_search_locations ?: [null];
357
        $results = [];
358
359
        foreach ($searchLocations as $searchLocation) {
360
            $records = $this->gateway->getUsers($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
361
            if (!$records) {
362
                continue;
363
            }
364
365
            foreach ($records as $record) {
366
                $results[$record['objectguid']] = $record;
367
            }
368
        }
369
370
        return $results;
371
    }