Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1691-1693 (lines=3) @@
1688
	 * @return bool
1689
	 */
1690
	public static function validate_alphanum( $value = '', $request, $param ) {
1691
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1692
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1693
		}
1694
		return true;
1695
	}
1696
@@ 1830-1832 (lines=3) @@
1827
	 * @return bool
1828
	 */
1829
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1830
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1831
			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 ) );
1832
		}
1833
1834
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1835
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1859-1861 (lines=3) @@
1856
	 * @return bool
1857
	 */
1858
	public static function validate_twitter_username( $value = '', $request, $param ) {
1859
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1860
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1861
		}
1862
		return true;
1863
	}
1864