Code Duplication    Length = 6-10 lines in 3 locations

code/services/LDAPService.php 3 locations

@@ 193-202 (lines=10) @@
190
191
        if (!$results || !$cached) {
192
            $results = array();
193
            foreach ($searchLocations as $searchLocation) {
194
                $records = $this->gateway->getGroups($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
195
                if (!$records) {
196
                    continue;
197
                }
198
199
                foreach ($records as $record) {
200
                    $results[$record[$indexBy]] = $record;
201
                }
202
            }
203
204
            $cache->save($results);
205
        }
@@ 226-231 (lines=6) @@
223
224
        $searchLocations = $this->config()->groups_search_locations ?: array(null);
225
        $results = array();
226
        foreach ($searchLocations as $searchLocation) {
227
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
228
            foreach ($records as $record) {
229
                $results[$record['dn']] = $record;
230
            }
231
        }
232
233
        self::$_cache_nested_groups[$dn] = $results;
234
        return $results;
@@ 286-295 (lines=10) @@
283
        $searchLocations = $this->config()->users_search_locations ?: array(null);
284
        $results = array();
285
286
        foreach ($searchLocations as $searchLocation) {
287
            $records = $this->gateway->getUsers($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
288
            if (!$records) {
289
                continue;
290
            }
291
292
            foreach ($records as $record) {
293
                $results[$record['objectguid']] = $record;
294
            }
295
        }
296
297
        return $results;
298
    }