Code Duplication    Length = 20-20 lines in 2 locations

engine/classes/ElggAnnotation.php 1 location

@@ 37-56 (lines=20) @@
34
	 *
35
	 * @param \stdClass $row Database row as \stdClass object
36
	 */
37
	public function __construct($row = null) {
38
		$this->initializeAttributes();
39
40
		if (!empty($row)) {
41
			// Create from db row
42
			if ($row instanceof \stdClass) {
43
				$annotation = $row;
44
45
				$objarray = (array) $annotation;
46
				foreach ($objarray as $key => $value) {
47
					$this->attributes[$key] = $value;
48
				}
49
			} else {
50
				// get an \ElggAnnotation object and copy its attributes
51
				elgg_deprecated_notice('Passing an ID to constructor is deprecated. Use elgg_get_annotation_from_id()', 1.9);
52
				$annotation = elgg_get_annotation_from_id($row);
53
				$this->attributes = $annotation->attributes;
54
			}
55
		}
56
	}
57
58
	/**
59
	 * Save this instance

engine/classes/ElggMetadata.php 1 location

@@ 37-56 (lines=20) @@
34
	 *
35
	 * @param \stdClass $row Database row as \stdClass object
36
	 */
37
	public function __construct($row = null) {
38
		$this->initializeAttributes();
39
40
		if (!empty($row)) {
41
			// Create from db row
42
			if ($row instanceof \stdClass) {
43
				$metadata = $row;
44
				
45
				$objarray = (array) $metadata;
46
				foreach ($objarray as $key => $value) {
47
					$this->attributes[$key] = $value;
48
				}
49
			} else {
50
				// get an \ElggMetadata object and copy its attributes
51
				elgg_deprecated_notice('Passing an ID to constructor is deprecated. Use elgg_get_metadata_from_id()', 1.9);
52
				$metadata = elgg_get_metadata_from_id($row);
53
				$this->attributes = $metadata->attributes;
54
			}
55
		}
56
	}
57
58
	/**
59
	 * Determines whether or not the user can edit this piece of metadata