Code Duplication    Length = 3-3 lines in 4 locations

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

@@ 2036-2038 (lines=3) @@
2033
	 * @return bool|WP_Error
2034
	 */
2035
	public static function validate_alphanum( $value = '', $request, $param ) {
2036
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^[a-z0-9]+$/i', $value ) ) ) {
2037
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
2038
		}
2039
		return true;
2040
	}
2041
@@ 2054-2056 (lines=3) @@
2051
	 * @return bool|WP_Error
2052
	 */
2053
	public static function validate_verification_service( $value = '', $request, $param ) {
2054
		if ( ! empty( $value ) && ! ( is_string( $value ) && ( preg_match( '/^[a-z0-9_-]+$/i', $value ) || preg_match( '#^<meta name="([a-z0-9_\-.:]+)?" content="([a-z0-9_-]+)?" />$#i', $value ) ) ) ) {
2055
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ), $param ) );
2056
		}
2057
		return true;
2058
	}
2059
@@ 2196-2198 (lines=3) @@
2193
	 * @return bool|WP_Error
2194
	 */
2195
	public static function validate_custom_service_id( $value = '', $request, $param ) {
2196
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
2197
			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 ) );
2198
		}
2199
2200
		if ( ! class_exists( 'Sharing_Service' ) && ! include_once( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
2201
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 2225-2227 (lines=3) @@
2222
	 * @return bool|WP_Error
2223
	 */
2224
	public static function validate_twitter_username( $value = '', $request, $param ) {
2225
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
2226
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
2227
		}
2228
		return true;
2229
	}
2230