Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1870-1872 (lines=3) @@
1867
1868
			// If it's an associative array, use the keys to check that the value is among those admitted.
1869
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1870
			if ( ! in_array( $value, $enum ) ) {
1871
				return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be one of %s', 'jetpack' ), $param, implode( ', ', $enum ) ) );
1872
			}
1873
		}
1874
		return true;
1875
	}
@@ 1933-1935 (lines=3) @@
1930
	 */
1931
	public static function validate_sharing_show( $value, $request, $param ) {
1932
		$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' );
1933
		if ( ! array_intersect( $views, $value ) ) {
1934
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be %s.', 'jetpack' ), $param, join( ', ', $views ) ) );
1935
		}
1936
		return true;
1937
	}
1938
@@ 2031-2033 (lines=3) @@
2028
		$sharer = new Sharing_Service();
2029
		$services = array_keys( $sharer->get_all_services() );
2030
2031
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2032
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2033
		}
2034
2035
		return true;
2036
	}