Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1590-1592 (lines=3) @@
1587
	 * @return bool
1588
	 */
1589
	public static function validate_alphanum( $value = '', $request, $param ) {
1590
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1591
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1592
		}
1593
		return true;
1594
	}
1595
@@ 1729-1731 (lines=3) @@
1726
	 * @return bool
1727
	 */
1728
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1729
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1730
			return new WP_Error( 'invalid_param', sprintf( esc_html__( "%s must be a string prefixed with 'custom-' and followed by a numeric ID.", 'jetpack' ), $param ) );
1731
		}
1732
1733
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1734
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1758-1760 (lines=3) @@
1755
	 * @return bool
1756
	 */
1757
	public static function validate_twitter_username( $value = '', $request, $param ) {
1758
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1759
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1760
		}
1761
		return true;
1762
	}
1763