Code Duplication    Length = 4-4 lines in 5 locations

class.jetpack-cli.php 5 locations

@@ 164-167 (lines=4) @@
161
		}
162
163
		$action = isset( $args[0] ) ? $args[0] : 'prompt';
164
		if ( ! in_array( $action, array( 'blog', 'user', 'prompt' ) ) ) {
165
			/* translators: %s is a command like "prompt" */
166
			WP_CLI::error( sprintf( __( '%s is not a valid command.', 'jetpack' ), $action ) );
167
		}
168
169
		if ( in_array( $action, array( 'user' ) ) ) {
170
			if ( isset( $args[1] ) ) {
@@ 234-237 (lines=4) @@
231
	 */
232
	public function reset( $args, $assoc_args ) {
233
		$action = isset( $args[0] ) ? $args[0] : 'prompt';
234
		if ( ! in_array( $action, array( 'options', 'modules' ) ) ) {
235
			/* translators: %s is a command like "prompt" */
236
			WP_CLI::error( sprintf( __( '%s is not a valid command.', 'jetpack' ), $action ) );
237
		}
238
239
		// Are you sure?
240
		jetpack_cli_are_you_sure();
@@ 315-318 (lines=4) @@
312
	 */
313
	public function module( $args, $assoc_args ) {
314
		$action = isset( $args[0] ) ? $args[0] : 'list';
315
		if ( ! in_array( $action, array( 'list', 'activate', 'deactivate', 'toggle' ) ) ) {
316
			/* translators: %s is a command like "prompt" */
317
			WP_CLI::error( sprintf( __( '%s is not a valid command.', 'jetpack' ), $action ) );
318
		}
319
		if ( in_array( $action, array( 'activate', 'deactivate', 'toggle' ) ) ) {
320
			if ( isset( $args[1] ) ) {
321
				$module_slug = $args[1];
@@ 399-402 (lines=4) @@
396
	 */
397
	public function protect( $args, $assoc_args ) {
398
		$action = isset( $args[0] ) ? $args[0] : 'prompt';
399
		if ( ! in_array( $action, array( 'whitelist' ) ) ) {
400
			/* translators: %s is a command like "prompt" */
401
			WP_CLI::error( sprintf( __( '%s is not a valid command.', 'jetpack' ), $action ) );
402
		}
403
		// Check if module is active
404
		if ( ! Jetpack::is_module_active( __FUNCTION__ ) ) {
405
			WP_CLI::error( sprintf( _x( '%s is not active. You can activate it with "wp jetpack module activate %s"', '"wp jetpack module activate" is a command - do not translate', 'jetpack' ), __FUNCTION__, __FUNCTION__ ) );
@@ 533-536 (lines=4) @@
530
		// Is the option flagged as unsafe?
531
		$flagged = ! in_array( $args[1], $safe_to_modify );
532
533
		if ( ! in_array( $action, array( 'list', 'get', 'delete', 'update' ) ) ) {
534
			/* translators: %s is a command like "prompt" */
535
			WP_CLI::error( sprintf( __( '%s is not a valid command.', 'jetpack' ), $action ) );
536
		}
537
538
		if ( isset( $args[0] ) ) {
539
			if ( 'get' == $args[0] && isset( $args[1] ) ) {