Code Duplication    Length = 10-14 lines in 3 locations

engine/classes/Elgg/Database/MetadataTable.php 3 locations

@@ 342-354 (lines=13) @@
339
	 * @param array $options An options array. {@link elgg_get_metadata()}
340
	 * @return bool|null true on success, false on failure, null if no metadata to delete.
341
	 */
342
	function deleteAll(array $options) {
343
		if (!_elgg_is_valid_options_for_batch_operation($options, 'metadata')) {
344
			return false;
345
		}
346
		$options['metastring_type'] = 'metadata';
347
		$result = _elgg_batch_metastring_based_objects($options, 'elgg_batch_delete_callback', false);
348
	
349
		// This moved last in case an object's constructor sets metadata. Currently the batch
350
		// delete process has to create the entity to delete its metadata. See #5214
351
		$this->cache->invalidateByOptions($options);
352
	
353
		return $result;
354
	}
355
	
356
	/**
357
	 * Disables metadata based on $options.
@@ 364-377 (lines=14) @@
361
	 * @param array $options An options array. {@link elgg_get_metadata()}
362
	 * @return bool|null true on success, false on failure, null if no metadata disabled.
363
	 */
364
	function disableAll(array $options) {
365
		if (!_elgg_is_valid_options_for_batch_operation($options, 'metadata')) {
366
			return false;
367
		}
368
	
369
		$this->cache->invalidateByOptions($options);
370
	
371
		// if we can see hidden (disabled) we need to use the offset
372
		// otherwise we risk an infinite loop if there are more than 50
373
		$inc_offset = access_get_show_hidden_status();
374
	
375
		$options['metastring_type'] = 'metadata';
376
		return _elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback', $inc_offset);
377
	}
378
	
379
	/**
380
	 * Enables metadata based on $options.
@@ 390-399 (lines=10) @@
387
	 * @param array $options An options array. {@link elgg_get_metadata()}
388
	 * @return bool|null true on success, false on failure, null if no metadata enabled.
389
	 */
390
	function enableAll(array $options) {
391
		if (!$options || !is_array($options)) {
392
			return false;
393
		}
394
	
395
		$this->cache->invalidateByOptions($options);
396
	
397
		$options['metastring_type'] = 'metadata';
398
		return _elgg_batch_metastring_based_objects($options, 'elgg_batch_enable_callback');
399
	}
400
	
401
	/**
402
	 * Returns entities based upon metadata.  Also accepts all