Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1720-1722 (lines=3) @@
1717
1718
			// If it's an associative array, use the keys to check that the value is among those admitted.
1719
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1720
			if ( ! in_array( $value, $enum ) ) {
1721
				return new WP_Error( 'invalid_param_value', sprintf(
1722
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
1723
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
1724
				) );
1725
			}
@@ 1748-1750 (lines=3) @@
1745
1746
		$modules = Jetpack::get_available_modules();
1747
1748
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
1749
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
1750
		}
1751
1752
		return true;
1753
	}
@@ 1937-1939 (lines=3) @@
1934
		$sharer = new Sharing_Service();
1935
		$services = array_keys( $sharer->get_all_services() );
1936
1937
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
1938
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
1939
		}
1940
1941
		return true;
1942
	}