Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1789-1791 (lines=3) @@
1786
	 * @return bool
1787
	 */
1788
	public static function validate_alphanum( $value = '', $request, $param ) {
1789
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1790
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1791
		}
1792
		return true;
1793
	}
1794
@@ 1896-1898 (lines=3) @@
1893
	 * @return bool
1894
	 */
1895
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1896
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1897
			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 ) );
1898
		}
1899
1900
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharing/sharing-service.php' ) ) {
1901
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1925-1927 (lines=3) @@
1922
	 * @return bool
1923
	 */
1924
	public static function validate_twitter_username( $value = '', $request, $param ) {
1925
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1926
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1927
		}
1928
		return true;
1929
	}
1930