Code Duplication    Length = 6-10 lines in 3 locations

code/services/LDAPService.php 3 locations

@@ 173-182 (lines=10) @@
170
171
        if (!$results || !$cached) {
172
            $results = array();
173
            foreach ($searchLocations as $searchLocation) {
174
                $records = $this->gateway->getGroups($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
175
                if (!$records) {
176
                    continue;
177
                }
178
179
                foreach ($records as $record) {
180
                    $results[$record[$indexBy]] = $record;
181
                }
182
            }
183
184
            $cache->save($results);
185
        }
@@ 206-211 (lines=6) @@
203
204
        $searchLocations = $this->config()->groups_search_locations ?: array(null);
205
        $results = array();
206
        foreach ($searchLocations as $searchLocation) {
207
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
208
            foreach ($records as $record) {
209
                $results[$record['dn']] = $record;
210
            }
211
        }
212
213
        self::$_cache_nested_groups[$dn] = $results;
214
        return $results;
@@ 266-275 (lines=10) @@
263
        $searchLocations = $this->config()->users_search_locations ?: array(null);
264
        $results = array();
265
266
        foreach ($searchLocations as $searchLocation) {
267
            $records = $this->gateway->getUsers($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
268
            if (!$records) {
269
                continue;
270
            }
271
272
            foreach ($records as $record) {
273
                $results[$record['objectguid']] = $record;
274
            }
275
        }
276
277
        return $results;
278
    }