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

@@ 3078-3088 (lines=11) @@
3075
		// one key per option, each having a boolean value. Extract those keys.
3076
		$multiselectOptions = [];
3077
		foreach ( $prefs as $name => $info ) {
3078
			if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
3079
					( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) {
3080
				$opts = HTMLFormField::flattenOptions( $info['options'] );
3081
				$prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
3082
3083
				foreach ( $opts as $value ) {
3084
					$multiselectOptions["$prefix$value"] = true;
3085
				}
3086
3087
				unset( $prefs[$name] );
3088
			}
3089
		}
3090
		$checkmatrixOptions = [];
3091
		foreach ( $prefs as $name => $info ) {