Code Duplication    Length = 6-10 lines in 3 locations

code/services/LDAPService.php 3 locations

@@ 210-219 (lines=10) @@
207
208
        if (!$results || !$cached) {
209
            $results = [];
210
            foreach ($searchLocations as $searchLocation) {
211
                $records = $this->gateway->getGroups($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
212
                if (!$records) {
213
                    continue;
214
                }
215
216
                foreach ($records as $record) {
217
                    $results[$record[$indexBy]] = $record;
218
                }
219
            }
220
221
            $cache->save($results);
222
        }
@@ 243-248 (lines=6) @@
240
241
        $searchLocations = $this->config()->groups_search_locations ?: [null];
242
        $results = [];
243
        foreach ($searchLocations as $searchLocation) {
244
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
245
            foreach ($records as $record) {
246
                $results[$record['dn']] = $record;
247
            }
248
        }
249
250
        self::$_cache_nested_groups[$dn] = $results;
251
        return $results;
@@ 303-312 (lines=10) @@
300
        $searchLocations = $this->config()->users_search_locations ?: [null];
301
        $results = [];
302
303
        foreach ($searchLocations as $searchLocation) {
304
            $records = $this->gateway->getUsers($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
305
            if (!$records) {
306
                continue;
307
            }
308
309
            foreach ($records as $record) {
310
                $results[$record['objectguid']] = $record;
311
            }
312
        }
313
314
        return $results;
315
    }