hex   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A to_hex() 0 3 1
A to_cmyk() 0 3 1
A to_hsl() 0 3 1
A to_hsb() 0 3 1
A to_rgb() 0 8 1
1
<?php
2
3
namespace projectcleverweb\color\convert;
4
5
class hex implements \projectcleverweb\color\interfaces\converter {
6
	use \projectcleverweb\color\traits\converter;
7
	
8
	protected static $default_value = '000000';
9
	
10
	public static function to_rgb($input) :array {
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