Code Duplication    Length = 17-17 lines in 2 locations

projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-token-subscription-service.php 1 location

@@ 247-263 (lines=17) @@
244
	 *
245
	 * @return array<int, array>
246
	 */
247
	public static function abbreviate_subscriptions( $subscriptions_from_bd ) {
248
		$subscriptions = array();
249
		foreach ( $subscriptions_from_bd as $subscription ) {
250
			// We are picking the expiry date that is the most in the future.
251
			if (
252
				'active' === $subscription['status'] && (
253
					! isset( $subscriptions[ $subscription['product_id'] ] ) ||
254
					empty( $subscription['end_date'] ) || // Special condition when subscription has no expiry date - we will default to a year from now for the purposes of the token.
255
					strtotime( $subscription['end_date'] ) > strtotime( (string) $subscriptions[ $subscription['product_id'] ]['end_date'] )
256
				)
257
			) {
258
				$subscriptions[ $subscription['product_id'] ]           = new \stdClass();
259
				$subscriptions[ $subscription['product_id'] ]->end_date = empty( $subscription['end_date'] ) ? ( time() + 365 * 24 * 3600 ) : $subscription['end_date'];
260
			}
261
		}
262
		return $subscriptions;
263
	}
264
}
265

projects/plugins/jetpack/extensions/blocks/premium-content/_inc/subscription-service/class-wpcom-offline-subscription-service.php 1 location

@@ 60-76 (lines=17) @@
57
	 *
58
	 * @return array<int, array>
59
	 */
60
	public static function abbreviate_subscriptions( $subscriptions_from_bd ) {
61
		$subscriptions = array();
62
		foreach ( $subscriptions_from_bd as $subscription ) {
63
			// We are picking the expiry date that is the most in the future.
64
			if (
65
				'active' === $subscription['status'] && (
66
					! isset( $subscriptions[ $subscription['product_id'] ] ) ||
67
					empty( $subscription['end_date'] ) || // Special condition when subscription has no expiry date - we will default to a year from now for the purposes of the token.
68
					strtotime( $subscription['end_date'] ) > strtotime( (string) $subscriptions[ $subscription['product_id'] ]['end_date'] )
69
				)
70
			) {
71
				$subscriptions[ $subscription['product_id'] ]           = new \stdClass();
72
				$subscriptions[ $subscription['product_id'] ]->end_date = empty( $subscription['end_date'] ) ? ( time() + 365 * 24 * 3600 ) : $subscription['end_date'];
73
			}
74
		}
75
		return $subscriptions;
76
	}
77
}
78