Code Duplication    Length = 6-10 lines in 3 locations

src/Services/LDAPService.php 3 locations

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