Code Duplication    Length = 13-15 lines in 6 locations

Contrib/less.php/Less.php 6 locations

@@ 3246-3260 (lines=15) @@
3243
	/**
3244
	 * @param Less_Tree_Dimension $amount
3245
	 */
3246
	public function desaturate($color = null, $amount = null){
3247
		if (!$color instanceof Less_Tree_Color) {
3248
			throw new Less_Exception_Compiler('The first argument to desaturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3249
		}
3250
		if (!$amount instanceof Less_Tree_Dimension) {
3251
			throw new Less_Exception_Compiler('The second argument to desaturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3252
		}
3253
3254
		$hsl = $color->toHSL();
3255
3256
		$hsl['s'] -= $amount->value / 100;
3257
		$hsl['s'] = self::clamp($hsl['s']);
3258
3259
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3260
	}
3261
3262
3263
@@ 3264-3278 (lines=15) @@
3261
3262
3263
3264
	public function lighten($color = null, $amount=null){
3265
		if (!$color instanceof Less_Tree_Color) {
3266
			throw new Less_Exception_Compiler('The first argument to lighten must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3267
		}
3268
		if (!$amount instanceof Less_Tree_Dimension) {
3269
			throw new Less_Exception_Compiler('The second argument to lighten must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3270
		}
3271
3272
		$hsl = $color->toHSL();
3273
3274
		$hsl['l'] += $amount->value / 100;
3275
		$hsl['l'] = self::clamp($hsl['l']);
3276
3277
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3278
	}
3279
3280
	public function darken($color = null, $amount = null){
3281
		if (!$color instanceof Less_Tree_Color) {
@@ 3280-3293 (lines=14) @@
3277
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3278
	}
3279
3280
	public function darken($color = null, $amount = null){
3281
		if (!$color instanceof Less_Tree_Color) {
3282
			throw new Less_Exception_Compiler('The first argument to darken must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3283
		}
3284
		if (!$amount instanceof Less_Tree_Dimension) {
3285
			throw new Less_Exception_Compiler('The second argument to darken must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3286
		}
3287
3288
		$hsl = $color->toHSL();
3289
		$hsl['l'] -= $amount->value / 100;
3290
		$hsl['l'] = self::clamp($hsl['l']);
3291
3292
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3293
	}
3294
3295
	public function fadein($color = null, $amount = null){
3296
		if (!$color instanceof Less_Tree_Color) {
@@ 3295-3307 (lines=13) @@
3292
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3293
	}
3294
3295
	public function fadein($color = null, $amount = null){
3296
		if (!$color instanceof Less_Tree_Color) {
3297
			throw new Less_Exception_Compiler('The first argument to fadein must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3298
		}
3299
		if (!$amount instanceof Less_Tree_Dimension) {
3300
			throw new Less_Exception_Compiler('The second argument to fadein must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3301
		}
3302
3303
		$hsl = $color->toHSL();
3304
		$hsl['a'] += $amount->value / 100;
3305
		$hsl['a'] = self::clamp($hsl['a']);
3306
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3307
	}
3308
3309
	public function fadeout($color = null, $amount = null){
3310
		if (!$color instanceof Less_Tree_Color) {
@@ 3309-3321 (lines=13) @@
3306
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3307
	}
3308
3309
	public function fadeout($color = null, $amount = null){
3310
		if (!$color instanceof Less_Tree_Color) {
3311
			throw new Less_Exception_Compiler('The first argument to fadeout must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3312
		}
3313
		if (!$amount instanceof Less_Tree_Dimension) {
3314
			throw new Less_Exception_Compiler('The second argument to fadeout must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3315
		}
3316
3317
		$hsl = $color->toHSL();
3318
		$hsl['a'] -= $amount->value / 100;
3319
		$hsl['a'] = self::clamp($hsl['a']);
3320
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3321
	}
3322
3323
	public function fade($color = null, $amount = null){
3324
		if (!$color instanceof Less_Tree_Color) {
@@ 3323-3336 (lines=14) @@
3320
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3321
	}
3322
3323
	public function fade($color = null, $amount = null){
3324
		if (!$color instanceof Less_Tree_Color) {
3325
			throw new Less_Exception_Compiler('The first argument to fade must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3326
		}
3327
		if (!$amount instanceof Less_Tree_Dimension) {
3328
			throw new Less_Exception_Compiler('The second argument to fade must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') );
3329
		}
3330
3331
		$hsl = $color->toHSL();
3332
3333
		$hsl['a'] = $amount->value / 100;
3334
		$hsl['a'] = self::clamp($hsl['a']);
3335
		return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
3336
	}
3337
3338
3339