Code Duplication    Length = 12-12 lines in 2 locations

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

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