Completed
Push — master ( e54ee7...8a8153 )
by Nicholas
03:13
created

main::light()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
crap 2
1
<?php
2
3
4
namespace projectcleverweb\color;
5
6
7
class main {
8
	
9
	public $color;
10
	
11
	public function __construct($color) {
12
		$this->set($color);
13
	}
14
	
15
	public function set($color) {
16
		if ($color instanceof color) {
17
			$this->color = $color;
18
		} else {
19
			$this->color = new color($color);
20
		}
21
	}
22
	
23
	public function is_dark(int $check_score = 128) :bool {
24
		$rgb = $this->color->rgb;
25
		return check::is_dark($rgb['r'], $rgb['g'], $rgb['b'], $check_score);
26
	}
27
	
28
	public function red(float $adjustment, bool $as_percentage = FALSE, bool $set_absolute = TRUE) {
29
		return modify::rgb($this->color, 'red', $adjustment, $as_percentage, $set_absolute);
30
	}
31
	
32
	public function green(float $adjustment, bool $as_percentage = FALSE, bool $set_absolute = TRUE) {
33
		return modify::rgb($this->color, 'green', $adjustment, $as_percentage, $set_absolute);
34
	}
35
	
36
	public function blue(float $adjustment, bool $as_percentage = FALSE, bool $set_absolute = TRUE) {
37
		return modify::rgb($this->color, 'blue', $adjustment, $as_percentage, $set_absolute);
38
	}
39
	
40
	public function hue(float $adjustment, bool $as_percentage = FALSE, bool $set_absolute = TRUE) {
41
		return modify::hsl($this->color, 'hue', $adjustment, $as_percentage, $set_absolute);
42
	}
43
	
44
	public function saturation(float $adjustment, bool $as_percentage = FALSE, bool $set_absolute = TRUE) {
45
		return modify::hsl($this->color, 'saturation', $adjustment, $as_percentage, $set_absolute);
46
	}
47
	
48
	public function light(float $adjustment, bool $as_percentage = FALSE, bool $set_absolute = TRUE) {
49
		return modify::hsl($this->color, 'light', $adjustment, $as_percentage, $set_absolute);
50
	}
51
	
52
	public function get_scheme(string $scheme_name = '') {
53
		if (is_callable(array(__NAMESPACE__.'\\scheme', $scheme_name))) {
54
			$hsl = $this->color->hsl;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
55
			$scheme = call_user_func_array(array(__NAMESPACE__.'\\scheme', $scheme_name), $hsl['h'], $hsl['s'], $hsl['l']);
56
			foreach ($scheme as &$val) {
57
				$val = generate::hsl_to_rgb($val['h'], $val['s'], $val['l']);
58
			}
59
			return $scheme;
60
		}
61
	}
62
	
63
	public function get_hex_scheme(string $scheme_name = '') {
0 ignored issues
show
Unused Code introduced by
The parameter $scheme_name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
		
65
	}
66
}
67