Code Duplication    Length = 11-12 lines in 2 locations

includes/Preferences.php 1 location

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

includes/user/User.php 1 location

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