Code Duplication    Length = 3-3 lines in 3 locations

_inc/lib/class.core-rest-api-endpoints.php 3 locations

@@ 2287-2289 (lines=3) @@
2284
2285
			// If it's an associative array, use the keys to check that the value is among those admitted.
2286
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
2287
			if ( ! in_array( $value, $enum ) ) {
2288
				return new WP_Error( 'invalid_param_value', sprintf(
2289
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
2290
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
2291
				) );
2292
			}
@@ 2315-2317 (lines=3) @@
2312
2313
		$modules = Jetpack::get_available_modules();
2314
2315
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
2316
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
2317
		}
2318
2319
		return true;
2320
	}
@@ 2504-2506 (lines=3) @@
2501
		$sharer = new Sharing_Service();
2502
		$services = array_keys( $sharer->get_all_services() );
2503
2504
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2505
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2506
		}
2507
2508
		return true;
2509
	}