Code Duplication    Length = 11-12 lines in 2 locations

includes/Preferences.php 1 location

@@ 168-179 (lines=12) @@
165
		$val = $user->getOption( $name );
166
167
		// Handling for multiselect preferences
168
		if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
169
				( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) {
170
			$options = HTMLFormField::flattenOptions( $info['options'] );
171
			$prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
172
			$val = [];
173
174
			foreach ( $options as $value ) {
175
				if ( $user->getOption( "$prefix$value" ) ) {
176
					$val[] = $value;
177
				}
178
			}
179
		}
180
181
		// Handling for checkmatrix preferences
182
		if ( ( isset( $info['type'] ) && $info['type'] == 'checkmatrix' ) ||

includes/user/User.php 1 location

@@ 2980-2990 (lines=11) @@
2977
		// one key per option, each having a boolean value. Extract those keys.
2978
		$multiselectOptions = [];
2979
		foreach ( $prefs as $name => $info ) {
2980
			if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
2981
					( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) {
2982
				$opts = HTMLFormField::flattenOptions( $info['options'] );
2983
				$prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
2984
2985
				foreach ( $opts as $value ) {
2986
					$multiselectOptions["$prefix$value"] = true;
2987
				}
2988
2989
				unset( $prefs[$name] );
2990
			}
2991
		}
2992
		$checkmatrixOptions = [];
2993
		foreach ( $prefs as $name => $info ) {