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

@@ 2955-2965 (lines=11) @@
2952
		// one key per option, each having a boolean value. Extract those keys.
2953
		$multiselectOptions = [];
2954
		foreach ( $prefs as $name => $info ) {
2955
			if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
2956
					( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) {
2957
				$opts = HTMLFormField::flattenOptions( $info['options'] );
2958
				$prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
2959
2960
				foreach ( $opts as $value ) {
2961
					$multiselectOptions["$prefix$value"] = true;
2962
				}
2963
2964
				unset( $prefs[$name] );
2965
			}
2966
		}
2967
		$checkmatrixOptions = [];
2968
		foreach ( $prefs as $name => $info ) {