Code Duplication    Length = 3-3 lines in 3 locations

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

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