Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1710-1712 (lines=3) @@
1707
1708
			// If it's an associative array, use the keys to check that the value is among those admitted.
1709
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1710
			if ( ! in_array( $value, $enum ) ) {
1711
				return new WP_Error( 'invalid_param_value', sprintf(
1712
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
1713
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
1714
				) );
1715
			}
@@ 1738-1740 (lines=3) @@
1735
1736
		$modules = Jetpack::get_available_modules();
1737
1738
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
1739
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
1740
		}
1741
1742
		return true;
1743
	}
@@ 1909-1911 (lines=3) @@
1906
		$sharer = new Sharing_Service();
1907
		$services = array_keys( $sharer->get_all_services() );
1908
1909
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
1910
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
1911
		}
1912
1913
		return true;
1914
	}