Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1705-1707 (lines=3) @@
1702
	 * @return bool
1703
	 */
1704
	public static function validate_alphanum( $value = '', $request, $param ) {
1705
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/[a-z0-9]+/i', $value ) ) ) {
1706
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
1707
		}
1708
		return true;
1709
	}
1710
@@ 1844-1846 (lines=3) @@
1841
	 * @return bool
1842
	 */
1843
	public static function validate_custom_service_id( $value = '', $request, $param ) {
1844
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/custom\-[0-1]+/i', $value ) ) ) {
1845
			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 ) );
1846
		}
1847
1848
		if ( ! class_exists( 'Sharing_Service' ) && ! @include( JETPACK__PLUGIN_DIR . 'modules/sharedaddy/sharing-service.php' ) ) {
1849
			return new WP_Error( 'invalid_param', esc_html__( 'Failed loading required dependency Sharing_Service.', 'jetpack' ) );
@@ 1873-1875 (lines=3) @@
1870
	 * @return bool
1871
	 */
1872
	public static function validate_twitter_username( $value = '', $request, $param ) {
1873
		if ( ! empty( $value ) && ( ! is_string( $value ) || ! preg_match( '/^@?\w{1,15}$/i', $value ) ) ) {
1874
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be a Twitter username.', 'jetpack' ), $param ) );
1875
		}
1876
		return true;
1877
	}
1878