Code Duplication    Length = 12-12 lines in 2 locations

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

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