Code Duplication    Length = 18-19 lines in 2 locations

packages/sync/src/modules/Constants.php 1 location

@@ 176-193 (lines=18) @@
173
174
		$constants_checksums = (array) get_option( self::CONSTANTS_CHECKSUM_OPTION_NAME, array() );
175
176
		foreach ( $constants as $name => $value ) {
177
			$checksum = $this->get_check_sum( $value );
178
			// Explicitly not using Identical comparison as get_option returns a string.
179
			if ( ! $this->still_valid_checksum( $constants_checksums, $name, $checksum ) && ! is_null( $value ) ) {
180
				/**
181
				 * Tells the client to sync a constant to the server
182
				 *
183
				 * @since 4.2.0
184
				 *
185
				 * @param string The name of the constant
186
				 * @param mixed The value of the constant
187
				 */
188
				do_action( 'jetpack_sync_constant', $name, $value );
189
				$constants_checksums[ $name ] = $checksum;
190
			} else {
191
				$constants_checksums[ $name ] = $checksum;
192
			}
193
		}
194
		update_option( self::CONSTANTS_CHECKSUM_OPTION_NAME, $constants_checksums );
195
	}
196

packages/sync/src/modules/Callables.php 1 location

@@ 418-436 (lines=19) @@
415
		$callable_checksums = (array) \Jetpack_Options::get_raw_option( self::CALLABLES_CHECKSUM_OPTION_NAME, array() );
416
		$has_changed        = false;
417
		// Only send the callables that have changed.
418
		foreach ( $callables as $name => $value ) {
419
			$checksum = $this->get_check_sum( $value );
420
			// Explicitly not using Identical comparison as get_option returns a string.
421
			if ( ! is_null( $value ) && $this->should_send_callable( $callable_checksums, $name, $checksum ) ) {
422
				/**
423
				 * Tells the client to sync a callable (aka function) to the server
424
				 *
425
				 * @since 4.2.0
426
				 *
427
				 * @param string The name of the callable
428
				 * @param mixed The value of the callable
429
				 */
430
				do_action( 'jetpack_sync_callable', $name, $value );
431
				$callable_checksums[ $name ] = $checksum;
432
				$has_changed                 = true;
433
			} else {
434
				$callable_checksums[ $name ] = $checksum;
435
			}
436
		}
437
		if ( $has_changed ) {
438
			\Jetpack_Options::update_raw_option( self::CALLABLES_CHECKSUM_OPTION_NAME, $callable_checksums );
439
		}