Code Duplication    Length = 3-3 lines in 3 locations

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

@@ 1589-1591 (lines=3) @@
1586
1587
			// If it's an associative array, use the keys to check that the value is among those admitted.
1588
			$enum = ( count( array_filter( array_keys( $args['enum'] ), 'is_string' ) ) > 0 ) ? array_keys( $args['enum'] ) : $args['enum'];
1589
			if ( ! in_array( $value, $enum ) ) {
1590
				return new WP_Error( 'invalid_param_value', sprintf(
1591
					/* Translators: first variable is the parameter passed to endpoint that holds the list item, the second is a list of admitted values. */
1592
					esc_html__( '%1$s must be one of %2$s', 'jetpack' ), $param, implode( ', ', $enum )
1593
				) );
1594
			}
@@ 1617-1619 (lines=3) @@
1614
1615
		$modules = Jetpack::get_available_modules();
1616
1617
		if ( count( array_intersect( $value, $modules ) ) != count( $value ) ) {
1618
			return new WP_Error( 'invalid_param_value', sprintf( esc_html__( '%s must be a list of valid modules', 'jetpack' ), $param ) );
1619
		}
1620
1621
		return true;
1622
	}
@@ 1785-1787 (lines=3) @@
1782
		$sharer = new Sharing_Service();
1783
		$services = array_keys( $sharer->get_all_services() );
1784
1785
		if ( ! empty( $value ) && ! in_array( $value, $services ) ) {
1786
			return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s is not a registered custom sharing service.', 'jetpack' ), $param ) );
1787
		}
1788
1789
		return true;
1790
	}