Code Duplication    Length = 12-12 lines in 2 locations

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

@@ 752-763 (lines=12) @@
749
				$error = '';
750
751
				$activated_count = count( $activated );
752
				if ( $activated_count > 0 ) {
753
					$activated_last = array_pop( $activated );
754
					$activated_text = $activated_count > 1 ? sprintf(
755
						/* Translators: first variable is a list followed by a last item. Example: dog, cat and bird. */
756
						__( '%s and %s', 'jetpack' ),
757
						join( ', ', $activated ), $activated_last ) : $activated_last;
758
759
					$error = sprintf(
760
						/* Translators: the plural variable is a list followed by a last item. Example: dog, cat and bird. */
761
						_n( 'The module %s was activated.', 'The modules %s were activated.', $activated_count, 'jetpack' ),
762
						$activated_text ) . ' ';
763
				}
764
765
				$failed_count = count( $failed );
766
				if ( count( $failed ) > 0 ) {
@@ 766-777 (lines=12) @@
763
				}
764
765
				$failed_count = count( $failed );
766
				if ( count( $failed ) > 0 ) {
767
					$failed_last = array_pop( $failed );
768
					$failed_text = $failed_count > 1 ? sprintf(
769
						/* Translators: first variable is a list followed by a last item. Example: dog, cat and bird. */
770
						__( '%s and %s', 'jetpack' ),
771
						join( ', ', $failed ), $failed_last ) : $failed_last;
772
773
					$error = sprintf(
774
						/* Translators: the plural variable is a list followed by a last item. Example: dog, cat and bird. */
775
						_n( 'The module %s failed to be activated.', 'The modules %s failed to be activated.', $failed_count, 'jetpack' ),
776
						$failed_text ) . ' ';
777
				}
778
			}
779
			return new WP_Error( 'activation_failed', esc_html( $error ), array( 'status' => 424 ) );
780
		}