Code Duplication    Length = 7-8 lines in 5 locations

Contrib/less.php/Less.php 5 locations

@@ 3167-3173 (lines=7) @@
3164
		return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' );
3165
	}
3166
3167
	public function red($color = null) {
3168
		if (!$color instanceof Less_Tree_Color) {
3169
			throw new Less_Exception_Compiler('The first argument to red must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3170
		}
3171
3172
		return new Less_Tree_Dimension( $color->rgb[0] );
3173
	}
3174
3175
	public function green($color = null) {
3176
		if (!$color instanceof Less_Tree_Color) {
@@ 3175-3181 (lines=7) @@
3172
		return new Less_Tree_Dimension( $color->rgb[0] );
3173
	}
3174
3175
	public function green($color = null) {
3176
		if (!$color instanceof Less_Tree_Color) {
3177
			throw new Less_Exception_Compiler('The first argument to green must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3178
		}
3179
3180
		return new Less_Tree_Dimension( $color->rgb[1] );
3181
	}
3182
3183
	public function blue($color = null) {
3184
		if (!$color instanceof Less_Tree_Color) {
@@ 3183-3189 (lines=7) @@
3180
		return new Less_Tree_Dimension( $color->rgb[1] );
3181
	}
3182
3183
	public function blue($color = null) {
3184
		if (!$color instanceof Less_Tree_Color) {
3185
			throw new Less_Exception_Compiler('The first argument to blue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3186
		}
3187
3188
		return new Less_Tree_Dimension( $color->rgb[2] );
3189
	}
3190
3191
	public function alpha($color = null){
3192
		if (!$color instanceof Less_Tree_Color) {
@@ 3191-3198 (lines=8) @@
3188
		return new Less_Tree_Dimension( $color->rgb[2] );
3189
	}
3190
3191
	public function alpha($color = null){
3192
		if (!$color instanceof Less_Tree_Color) {
3193
			throw new Less_Exception_Compiler('The first argument to alpha must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3194
		}
3195
3196
		$c = $color->toHSL();
3197
		return new Less_Tree_Dimension($c['a']);
3198
	}
3199
3200
	public function luma ($color = null) {
3201
		if (!$color instanceof Less_Tree_Color) {
@@ 3703-3709 (lines=7) @@
3700
		return new Less_Tree_Anonymous($n->unit);
3701
	}
3702
3703
	public function argb($color) {
3704
		if (!$color instanceof Less_Tree_Color) {
3705
			throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3706
		}
3707
3708
		return new Less_Tree_Anonymous($color->toARGB());
3709
	}
3710
3711
	public function percentage($n) {
3712
		return new Less_Tree_Dimension($n->value * 100, '%');