hex::to_rgb()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 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