Code Duplication    Length = 12-12 lines in 2 locations

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

@@ 740-751 (lines=12) @@
737
				$error = '';
738
739
				$activated_count = count( $activated );
740
				if ( $activated_count > 0 ) {
741
					$activated_last = array_pop( $activated );
742
					$activated_text = $activated_count > 1 ? sprintf(
743
						/* Translators: first variable is a list followed by a last item. Example: dog, cat and bird. */
744
						__( '%s and %s', 'jetpack' ),
745
						join( ', ', $activated ), $activated_last ) : $activated_last;
746
747
					$error = sprintf(
748
						/* Translators: the plural variable is a list followed by a last item. Example: dog, cat and bird. */
749
						_n( 'The module %s was activated.', 'The modules %s were activated.', $activated_count, 'jetpack' ),
750
						$activated_text ) . ' ';
751
				}
752
753
				$failed_count = count( $failed );
754
				if ( count( $failed ) > 0 ) {
@@ 754-765 (lines=12) @@
751
				}
752
753
				$failed_count = count( $failed );
754
				if ( count( $failed ) > 0 ) {
755
					$failed_last = array_pop( $failed );
756
					$failed_text = $failed_count > 1 ? sprintf(
757
						/* Translators: first variable is a list followed by a last item. Example: dog, cat and bird. */
758
						__( '%s and %s', 'jetpack' ),
759
						join( ', ', $failed ), $failed_last ) : $failed_last;
760
761
					$error = sprintf(
762
						/* Translators: the plural variable is a list followed by a last item. Example: dog, cat and bird. */
763
						_n( 'The module %s failed to be activated.', 'The modules %s failed to be activated.', $failed_count, 'jetpack' ),
764
						$failed_text ) . ' ';
765
				}
766
			}
767
			return new WP_Error( 'activation_failed', esc_html( $error ), array( 'status' => 424 ) );
768
		}