Code Duplication    Length = 7-8 lines in 5 locations

Contrib/less.php/Less.php 5 locations

@@ 3159-3165 (lines=7) @@
3156
		return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' );
3157
	}
3158
3159
	public function red($color = null) {
3160
		if (!$color instanceof Less_Tree_Color) {
3161
			throw new Less_Exception_Compiler('The first argument to red must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3162
		}
3163
3164
		return new Less_Tree_Dimension( $color->rgb[0] );
3165
	}
3166
3167
	public function green($color = null) {
3168
		if (!$color instanceof Less_Tree_Color) {
@@ 3167-3173 (lines=7) @@
3164
		return new Less_Tree_Dimension( $color->rgb[0] );
3165
	}
3166
3167
	public function green($color = null) {
3168
		if (!$color instanceof Less_Tree_Color) {
3169
			throw new Less_Exception_Compiler('The first argument to green must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3170
		}
3171
3172
		return new Less_Tree_Dimension( $color->rgb[1] );
3173
	}
3174
3175
	public function blue($color = null) {
3176
		if (!$color instanceof Less_Tree_Color) {
@@ 3175-3181 (lines=7) @@
3172
		return new Less_Tree_Dimension( $color->rgb[1] );
3173
	}
3174
3175
	public function blue($color = null) {
3176
		if (!$color instanceof Less_Tree_Color) {
3177
			throw new Less_Exception_Compiler('The first argument to blue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3178
		}
3179
3180
		return new Less_Tree_Dimension( $color->rgb[2] );
3181
	}
3182
3183
	public function alpha($color = null){
3184
		if (!$color instanceof Less_Tree_Color) {
@@ 3183-3190 (lines=8) @@
3180
		return new Less_Tree_Dimension( $color->rgb[2] );
3181
	}
3182
3183
	public function alpha($color = null){
3184
		if (!$color instanceof Less_Tree_Color) {
3185
			throw new Less_Exception_Compiler('The first argument to alpha must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3186
		}
3187
3188
		$c = $color->toHSL();
3189
		return new Less_Tree_Dimension($c['a']);
3190
	}
3191
3192
	public function luma ($color = null) {
3193
		if (!$color instanceof Less_Tree_Color) {
@@ 3695-3701 (lines=7) @@
3692
		return new Less_Tree_Anonymous($n->unit);
3693
	}
3694
3695
	public function argb($color) {
3696
		if (!$color instanceof Less_Tree_Color) {
3697
			throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3698
		}
3699
3700
		return new Less_Tree_Anonymous($color->toARGB());
3701
	}
3702
3703
	public function percentage($n) {
3704
		return new Less_Tree_Dimension($n->value * 100, '%');