Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1503-1505 (lines=3) @@
1500
1501
			// If it's an associative array, use the keys to check that the value is among those admitted.
1502
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1503
			if ( ! in_array( $value, $enum ) ) {
1504
				return new WP_Error( 'invalid_param_value', sprintf(
1505
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
1506
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
1507
				) );
1508
			}
@@ 1531-1533 (lines=3) @@
1528
1529
		$modules = Jetpack::get_available_modules();
1530
1531
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
1532
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
1533
		}
1534
1535
		return true;
1536
	}
@@ 1699-1701 (lines=3) @@
1696
		$sharer = new Sharing_Service();
1697
		$services = array_keys( $sharer->get_all_services() );
1698
1699
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
1700
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
1701
		}
1702
1703
		return true;
1704
	}