Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1879-1881 (lines=3) @@
1876
1877
			// If it's an associative array, use the keys to check that the value is among those admitted.
1878
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1879
			if ( ! in_array( $value, $enum ) ) {
1880
				return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be one of %s', 'jetpack' ), $param, implode( ', ', $enum ) ) );
1881
			}
1882
		}
1883
		return true;
1884
	}
@@ 1942-1944 (lines=3) @@
1939
	 */
1940
	public static function validate_sharing_show( $value, $request, $param ) {
1941
		$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' );
1942
		if ( ! array_intersect( $views, $value ) ) {
1943
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be %s.', 'jetpack' ), $param, join( ', ', $views ) ) );
1944
		}
1945
		return true;
1946
	}
1947
@@ 2040-2042 (lines=3) @@
2037
		$sharer = new Sharing_Service();
2038
		$services = array_keys( $sharer->get_all_services() );
2039
2040
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2041
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2042
		}
2043
2044
		return true;
2045
	}