Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1858-1860 (lines=3) @@
1855
1856
			// If it's an associative array, use the keys to check that the value is among those admitted.
1857
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1858
			if ( ! in_array( $value, $enum ) ) {
1859
				return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be one of %s', 'jetpack' ), $param, implode( ', ', $enum ) ) );
1860
			}
1861
		}
1862
		return true;
1863
	}
@@ 1921-1923 (lines=3) @@
1918
	 */
1919
	public static function validate_sharing_show( $value, $request, $param ) {
1920
		$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' );
1921
		if ( ! array_intersect( $views, $value ) ) {
1922
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be %s.', 'jetpack' ), $param, join( ', ', $views ) ) );
1923
		}
1924
		return true;
1925
	}
1926
@@ 2019-2021 (lines=3) @@
2016
		$sharer = new Sharing_Service();
2017
		$services = array_keys( $sharer->get_all_services() );
2018
2019
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2020
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2021
		}
2022
2023
		return true;
2024
	}