Code Duplication    Length = 6-10 lines in 3 locations

code/services/LDAPService.php 3 locations

@@ 218-227 (lines=10) @@
215
216
        if (!$results || !$cached) {
217
            $results = [];
218
            foreach ($searchLocations as $searchLocation) {
219
                $records = $this->gateway->getGroups($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
220
                if (!$records) {
221
                    continue;
222
                }
223
224
                foreach ($records as $record) {
225
                    $results[$record[$indexBy]] = $record;
226
                }
227
            }
228
229
            $cache->save($results);
230
        }
@@ 251-256 (lines=6) @@
248
249
        $searchLocations = $this->config()->groups_search_locations ?: [null];
250
        $results = [];
251
        foreach ($searchLocations as $searchLocation) {
252
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
253
            foreach ($records as $record) {
254
                $results[$record['dn']] = $record;
255
            }
256
        }
257
258
        self::$_cache_nested_groups[$dn] = $results;
259
        return $results;
@@ 311-320 (lines=10) @@
308
        $searchLocations = $this->config()->users_search_locations ?: [null];
309
        $results = [];
310
311
        foreach ($searchLocations as $searchLocation) {
312
            $records = $this->gateway->getUsers($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
313
            if (!$records) {
314
                continue;
315
            }
316
317
            foreach ($records as $record) {
318
                $results[$record['objectguid']] = $record;
319
            }
320
        }
321
322
        return $results;
323
    }