Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1893-1895 (lines=3) @@
1890
1891
			// If it's an associative array, use the keys to check that the value is among those admitted.
1892
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1893
			if ( ! in_array( $value, $enum ) ) {
1894
				return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be one of %s', 'jetpack' ), $param, implode( ', ', $enum ) ) );
1895
			}
1896
		}
1897
		return true;
1898
	}
@@ 1956-1958 (lines=3) @@
1953
	 */
1954
	public static function validate_sharing_show( $value, $request, $param ) {
1955
		$views = array( 'index', 'post', 'page', 'attachment', 'jetpack-portfolio' );
1956
		if ( ! array_intersect( $views, $value ) ) {
1957
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be %s.', 'jetpack' ), $param, join( ', ', $views ) ) );
1958
		}
1959
		return true;
1960
	}
1961
@@ 2054-2056 (lines=3) @@
2051
		$sharer = new Sharing_Service();
2052
		$services = array_keys( $sharer->get_all_services() );
2053
2054
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
2055
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
2056
		}
2057
2058
		return true;
2059
	}