Test Failed
Push — master ( 2ae2a8...2e5515 )
by Nicholas
04:58
created

hex   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 26.67 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 8
loc 30
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A to_rgb() 8 8 1
A to_hex() 0 3 1
A to_cmyk() 0 3 1
A to_hsl() 0 3 1
A to_hsb() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace projectcleverweb\color\convert;
4
5
class hex implements \projectcleverweb\color\interfaces\converter {
6
	use \projectcleverweb\color\traits\convert\meta;
7
	
8
	protected static $default_value = '000000';
9
	
10 View Code Duplication
	public static function to_rgb($input) :array {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
		$hex = static::_validate_hex_input($input);
12
		return [
13
			'r' => hexdec(substr($hex, 0, 2)),
14
			'g' => hexdec(substr($hex, 2, 2)),
15
			'b' => hexdec(substr($hex, 4, 2))
16
		];
17
	}
18
	
19
	public static function to_hex($input) :string {
20
		return static::_validate_hex_input($input);
21
	}
22
	
23
	public static function to_cmyk($input) :array {
24
		return rgb::to_cmyk(static::to_rgb($input));
25
	}
26
	
27
	public static function to_hsl($input) :array {
28
		return rgb::to_hsl(static::to_rgb($input));
29
	}
30
	
31
	public static function to_hsb($input) :array {
32
		return rgb::to_hsb(static::to_rgb($input));
33
	}
34
}
35