Code Duplication    Length = 28-29 lines in 2 locations

includes/wc-formatting-functions.php 2 locations

@@ 524-551 (lines=28) @@
521
	}
522
}
523
524
if ( ! function_exists( 'wc_hex_darker' ) ) {
525
526
	/**
527
	 * Hex darker/lighter/contrast functions for colours.
528
	 *
529
	 * @param mixed $color
530
	 * @param int $factor (default: 30)
531
	 * @return string
532
	 */
533
	function wc_hex_darker( $color, $factor = 30 ) {
534
		$base  = wc_rgb_from_hex( $color );
535
		$color = '#';
536
537
		foreach ( $base as $k => $v ) {
538
			$amount      = $v / 100;
539
			$amount      = round( $amount * $factor );
540
			$new_decimal = $v - $amount;
541
542
			$new_hex_component = dechex( $new_decimal );
543
			if ( strlen( $new_hex_component ) < 2 ) {
544
				$new_hex_component = "0" . $new_hex_component;
545
			}
546
			$color .= $new_hex_component;
547
		}
548
549
		return $color;
550
	}
551
}
552
553
if ( ! function_exists( 'wc_hex_lighter' ) ) {
554
@@ 553-581 (lines=29) @@
550
	}
551
}
552
553
if ( ! function_exists( 'wc_hex_lighter' ) ) {
554
555
	/**
556
	 * Hex darker/lighter/contrast functions for colours.
557
	 *
558
	 * @param mixed $color
559
	 * @param int $factor (default: 30)
560
	 * @return string
561
	 */
562
	function wc_hex_lighter( $color, $factor = 30 ) {
563
		$base  = wc_rgb_from_hex( $color );
564
		$color = '#';
565
566
		foreach ( $base as $k => $v ) {
567
			$amount      = 255 - $v;
568
			$amount      = $amount / 100;
569
			$amount      = round( $amount * $factor );
570
			$new_decimal = $v + $amount;
571
572
			$new_hex_component = dechex( $new_decimal );
573
			if ( strlen( $new_hex_component ) < 2 ) {
574
				$new_hex_component = "0" . $new_hex_component;
575
			}
576
			$color .= $new_hex_component;
577
		}
578
579
		return $color;
580
	}
581
}
582
583
if ( ! function_exists( 'wc_light_or_dark' ) ) {
584