Code Duplication    Length = 6-10 lines in 3 locations

code/services/LDAPService.php 3 locations

@@ 181-190 (lines=10) @@
178
179
        if (!$results || !$cached) {
180
            $results = array();
181
            foreach ($searchLocations as $searchLocation) {
182
                $records = $this->gateway->getGroups($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
183
                if (!$records) {
184
                    continue;
185
                }
186
187
                foreach ($records as $record) {
188
                    $results[$record[$indexBy]] = $record;
189
                }
190
            }
191
192
            $cache->save($results);
193
        }
@@ 214-219 (lines=6) @@
211
212
        $searchLocations = $this->config()->groups_search_locations ?: array(null);
213
        $results = array();
214
        foreach ($searchLocations as $searchLocation) {
215
            $records = $this->gateway->getNestedGroups($dn, $searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
216
            foreach ($records as $record) {
217
                $results[$record['dn']] = $record;
218
            }
219
        }
220
221
        self::$_cache_nested_groups[$dn] = $results;
222
        return $results;
@@ 274-283 (lines=10) @@
271
        $searchLocations = $this->config()->users_search_locations ?: array(null);
272
        $results = array();
273
274
        foreach ($searchLocations as $searchLocation) {
275
            $records = $this->gateway->getUsers($searchLocation, Zend\Ldap\Ldap::SEARCH_SCOPE_SUB, $attributes);
276
            if (!$records) {
277
                continue;
278
            }
279
280
            foreach ($records as $record) {
281
                $results[$record['objectguid']] = $record;
282
            }
283
        }
284
285
        return $results;
286
    }