Code Duplication    Length = 12-12 lines in 2 locations

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

@@ 775-786 (lines=12) @@
772
				$error = '';
773
774
				$activated_count = count( $activated );
775
				if ( $activated_count > 0 ) {
776
					$activated_last = array_pop( $activated );
777
					$activated_text = $activated_count > 1 ? sprintf(
778
						/* Translators: first variable is a list followed by a last item. Example: dog, cat and bird. */
779
						__( '%s and %s', 'jetpack' ),
780
						join( ', ', $activated ), $activated_last ) : $activated_last;
781
782
					$error = sprintf(
783
						/* Translators: the plural variable is a list followed by a last item. Example: dog, cat and bird. */
784
						_n( 'The module %s was activated.', 'The modules %s were activated.', $activated_count, 'jetpack' ),
785
						$activated_text ) . ' ';
786
				}
787
788
				$failed_count = count( $failed );
789
				if ( count( $failed ) > 0 ) {
@@ 789-800 (lines=12) @@
786
				}
787
788
				$failed_count = count( $failed );
789
				if ( count( $failed ) > 0 ) {
790
					$failed_last = array_pop( $failed );
791
					$failed_text = $failed_count > 1 ? sprintf(
792
						/* Translators: first variable is a list followed by a last item. Example: dog, cat and bird. */
793
						__( '%s and %s', 'jetpack' ),
794
						join( ', ', $failed ), $failed_last ) : $failed_last;
795
796
					$error = sprintf(
797
						/* Translators: the plural variable is a list followed by a last item. Example: dog, cat and bird. */
798
						_n( 'The module %s failed to be activated.', 'The modules %s failed to be activated.', $failed_count, 'jetpack' ),
799
						$failed_text ) . ' ';
800
				}
801
			}
802
			return new WP_Error( 'activation_failed', esc_html( $error ), array( 'status' => 424 ) );
803
		}