Code Duplication    Length = 18-19 lines in 2 locations

packages/sync/legacy/class.jetpack-sync-module-constants.php 1 location

@@ 75-92 (lines=18) @@
72
73
		$constants_checksums = (array) get_option( self::CONSTANTS_CHECKSUM_OPTION_NAME, array() );
74
75
		foreach ( $constants as $name => $value ) {
76
			$checksum = $this->get_check_sum( $value );
77
			// explicitly not using Identical comparison as get_option returns a string
78
			if ( ! $this->still_valid_checksum( $constants_checksums, $name, $checksum ) && ! is_null( $value ) ) {
79
				/**
80
				 * Tells the client to sync a constant to the server
81
				 *
82
				 * @since 4.2.0
83
				 *
84
				 * @param string The name of the constant
85
				 * @param mixed The value of the constant
86
				 */
87
				do_action( 'jetpack_sync_constant', $name, $value );
88
				$constants_checksums[ $name ] = $checksum;
89
			} else {
90
				$constants_checksums[ $name ] = $checksum;
91
			}
92
		}
93
		update_option( self::CONSTANTS_CHECKSUM_OPTION_NAME, $constants_checksums );
94
	}
95

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

@@ 235-253 (lines=19) @@
232
		$callable_checksums = (array) \Jetpack_Options::get_raw_option( self::CALLABLES_CHECKSUM_OPTION_NAME, array() );
233
		$has_changed        = false;
234
		// only send the callables that have changed
235
		foreach ( $callables as $name => $value ) {
236
			$checksum = $this->get_check_sum( $value );
237
			// explicitly not using Identical comparison as get_option returns a string
238
			if ( ! is_null( $value ) && $this->should_send_callable( $callable_checksums, $name, $checksum ) ) {
239
				/**
240
				 * Tells the client to sync a callable (aka function) to the server
241
				 *
242
				 * @since 4.2.0
243
				 *
244
				 * @param string The name of the callable
245
				 * @param mixed The value of the callable
246
				 */
247
				do_action( 'jetpack_sync_callable', $name, $value );
248
				$callable_checksums[ $name ] = $checksum;
249
				$has_changed                 = true;
250
			} else {
251
				$callable_checksums[ $name ] = $checksum;
252
			}
253
		}
254
		if ( $has_changed ) {
255
			\Jetpack_Options::update_raw_option( self::CALLABLES_CHECKSUM_OPTION_NAME, $callable_checksums );
256
		}