Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1550-1552 (lines=3) @@
1547
	 * @return bool
1548
	 */
1549
	public static function validate_alphanum( $value = '', $request, $param ) {
1550
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1551
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1552
		}
1553
		return true;
1554
	}
1555
@@ 1689-1691 (lines=3) @@
1686
	 * @return bool
1687
	 */
1688
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1689
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1690
			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 ) );
1691
		}
1692
1693
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1694
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1718-1720 (lines=3) @@
1715
	 * @return bool
1716
	 */
1717
	public static function validate_twitter_username( $value = '', $request, $param ) {
1718
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1719
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1720
		}
1721
		return true;
1722
	}
1723