Code Duplication    Length = 6-10 lines in 3 locations

src/Services/LDAPService.php 3 locations

@@ 233-242 (lines=10) @@
230
231
        if (!$results || !$cached) {
232
            $results = [];
233
            foreach ($searchLocations as $searchLocation) {
234
                $records = $this->gateway->getGroups($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
235
                if (!$records) {
236
                    continue;
237
                }
238
239
                foreach ($records as $record) {
240
                    $results[$record[$indexBy]] = $record;
241
                }
242
            }
243
244
            $cache->save($results);
245
        }
@@ 266-271 (lines=6) @@
263
264
        $searchLocations = $this->config()->groups_search_locations ?: [null];
265
        $results = [];
266
        foreach ($searchLocations as $searchLocation) {
267
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
268
            foreach ($records as $record) {
269
                $results[$record['dn']] = $record;
270
            }
271
        }
272
273
        self::$_cache_nested_groups[$dn] = $results;
274
        return $results;
@@ 326-335 (lines=10) @@
323
        $searchLocations = $this->config()->users_search_locations ?: [null];
324
        $results = [];
325
326
        foreach ($searchLocations as $searchLocation) {
327
            $records = $this->gateway->getUsers($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
328
            if (!$records) {
329
                continue;
330
            }
331
332
            foreach ($records as $record) {
333
                $results[$record['objectguid']] = $record;
334
            }
335
        }
336
337
        return $results;
338
    }