Code Duplication    Length = 6-10 lines in 3 locations

src/Services/LDAPService.php 3 locations

@@ 241-250 (lines=10) @@
238
239
        if (!$results || !$cached) {
240
            $results = [];
241
            foreach ($searchLocations as $searchLocation) {
242
                $records = $this->gateway->getGroups($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
243
                if (!$records) {
244
                    continue;
245
                }
246
247
                foreach ($records as $record) {
248
                    $results[$record[$indexBy]] = $record;
249
                }
250
            }
251
252
            $cache->save($results);
253
        }
@@ 274-279 (lines=6) @@
271
272
        $searchLocations = $this->config()->groups_search_locations ?: [null];
273
        $results = [];
274
        foreach ($searchLocations as $searchLocation) {
275
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
276
            foreach ($records as $record) {
277
                $results[$record['dn']] = $record;
278
            }
279
        }
280
281
        self::$_cache_nested_groups[$dn] = $results;
282
        return $results;
@@ 334-343 (lines=10) @@
331
        $searchLocations = $this->config()->users_search_locations ?: [null];
332
        $results = [];
333
334
        foreach ($searchLocations as $searchLocation) {
335
            $records = $this->gateway->getUsers($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
336
            if (!$records) {
337
                continue;
338
            }
339
340
            foreach ($records as $record) {
341
                $results[$record['objectguid']] = $record;
342
            }
343
        }
344
345
        return $results;
346
    }