Code Duplication    Length = 18-19 lines in 2 locations

packages/sync/src/modules/class-callables.php 1 location

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

packages/sync/src/modules/class-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