Code Duplication    Length = 12-12 lines in 2 locations

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

@@ 673-684 (lines=12) @@
670
				$error = '';
671
672
				$activated_count = count( $activated );
673
				if ( $activated_count > 0 ) {
674
					$activated_last = array_pop( $activated );
675
					$activated_text = $activated_count > 1 ? sprintf(
676
						/* Translators: first variable is a list followed by a last item. Example: dog, cat and bird. */
677
						__( '%s and %s', 'jetpack' ),
678
						join( ', ', $activated ), $activated_last ) : $activated_last;
679
680
					$error = sprintf(
681
						/* Translators: the plural variable is a list followed by a last item. Example: dog, cat and bird. */
682
						_n( 'The module %s was activated.', 'The modules %s were activated.', $activated_count, 'jetpack' ),
683
						$activated_text ) . ' ';
684
				}
685
686
				$failed_count = count( $failed );
687
				if ( count( $failed ) > 0 ) {
@@ 687-698 (lines=12) @@
684
				}
685
686
				$failed_count = count( $failed );
687
				if ( count( $failed ) > 0 ) {
688
					$failed_last = array_pop( $failed );
689
					$failed_text = $failed_count > 1 ? sprintf(
690
						/* Translators: first variable is a list followed by a last item. Example: dog, cat and bird. */
691
						__( '%s and %s', 'jetpack' ),
692
						join( ', ', $failed ), $failed_last ) : $failed_last;
693
694
					$error = sprintf(
695
						/* Translators: the plural variable is a list followed by a last item. Example: dog, cat and bird. */
696
						_n( 'The module %s failed to be activated.', 'The modules %s failed to be activated.', $failed_count, 'jetpack' ),
697
						$failed_text ) . ' ';
698
				}
699
			}
700
			return new WP_Error( 'activation_failed', esc_html( $error ), array( 'status' => 424 ) );
701
		}