hsl::to_cmyk()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace projectcleverweb\color\convert;
4
5
class hsl implements \projectcleverweb\color\interfaces\converter {
6
	use \projectcleverweb\color\traits\converter;
7
	
8
	protected static $valid_keys = array(
9
		'h',
10
		's',
11
		'l'
12
	);
13
	
14
	protected static $default_value = array(
15
		'h' => 0,
16
		's' => 0,
17
		'l' => 0
18
	);
19
	
20
	public static function to_rgb($input) :array {
21
		$hsl = static::_validate_array_input($input);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
22
		$hsl['s'] /= 100;
23
		$hsl['l'] /= 100;
24
		$c  = (1 - abs((2 * $hsl['l']) - 1)) * $hsl['s'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
25
		$x  = $c * (1 - abs(fmod(($hsl['h'] / 60), 2) - 1));
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
26
		$m  = $hsl['l'] - ($c / 2);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
27
		$r  = $c;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
28
		$g  = 0;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
29
		$b  = $x;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 2 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
30
		
31
		if ($hsl['h'] < 180) {
32
			static::_hslrgb_low($r, $g, $b, $c, $x, $hsl['h']);
33
		} elseif ($hsl['h'] < 300) {
34
			static::_hslrgb_high($r, $g, $b, $c, $x, $hsl['h']);
35
		}
36
		
37
		return [
38
			'r' => (int) round(($r + $m) * 255),
39
			'g' => (int) round(($g + $m) * 255),
40
			'b' => (int) round(($b + $m) * 255)
41
		];
42
	}
43
	
44
	public static function to_hex($input) :string {
45
		return rgb::to_hex(static::to_rgb($input));
46
	}
47
	
48
	public static function to_cmyk($input) :array {
49
		return rgb::to_cmyk(static::to_rgb($input));
50
	}
51
	
52
	public static function to_hsl($input) :array {
53
		return static::_validate_array_input($input);
54
	}
55
	
56
	public static function to_hsb($input) :array {
57
		return rgb::to_hsb(static::to_rgb($input));
58
	}
59
}
60