Code Duplication    Length = 29-30 lines in 2 locations

includes/sensei-functions.php 2 locations

@@ 107-135 (lines=29) @@
104
	}
105
}
106
107
if ( ! function_exists( 'sensei_hex_darker' ) ) {
108
109
	/**
110
	 * Hex darker/lighter/contrast functions for colours
111
	 *
112
	 * @access public
113
	 * @param mixed $color
114
	 * @param int $factor (default: 30)
115
	 * @return string
116
	 */
117
	function sensei_hex_darker( $color, $factor = 30 ) {
118
		$base = sensei_rgb_from_hex( $color );
119
		$color = '#';
120
121
		foreach ($base as $k => $v) :
122
	        $amount = $v / 100;
123
	        $amount = round($amount * $factor);
124
	        $new_decimal = $v - $amount;
125
126
	        $new_hex_component = dechex($new_decimal);
127
	        if(strlen($new_hex_component) < 2) :
128
	        	$new_hex_component = "0".$new_hex_component;
129
	        endif;
130
	        $color .= $new_hex_component;
131
		endforeach;
132
133
		return $color;
134
	}
135
}
136
137
if ( ! function_exists( 'sensei_hex_lighter' ) ) {
138
@@ 137-166 (lines=30) @@
134
	}
135
}
136
137
if ( ! function_exists( 'sensei_hex_lighter' ) ) {
138
139
	/**
140
	 * Hex darker/lighter/contrast functions for colours
141
	 *
142
	 * @access public
143
	 * @param mixed $color
144
	 * @param int $factor (default: 30)
145
	 * @return string
146
	 */
147
	function sensei_hex_lighter( $color, $factor = 30 ) {
148
		$base = sensei_rgb_from_hex( $color );
149
		$color = '#';
150
151
	    foreach ($base as $k => $v) :
152
	        $amount = 255 - $v;
153
	        $amount = $amount / 100;
154
	        $amount = round($amount * $factor);
155
	        $new_decimal = $v + $amount;
156
157
	        $new_hex_component = dechex($new_decimal);
158
	        if(strlen($new_hex_component) < 2) :
159
	        	$new_hex_component = "0".$new_hex_component;
160
	        endif;
161
	        $color .= $new_hex_component;
162
	   	endforeach;
163
164
	   	return $color;
165
	}
166
}
167
168
/**
169
 * WC Detection for backwards compatibility