Completed
Push — master ( e3e926...51577e )
by Nicholas
02:23
created

main   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 14
c 0
b 0
f 0
lcom 2
cbo 4
dl 0
loc 60
ccs 0
cts 33
cp 0
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A set() 0 7 2
A is_dark() 0 4 1
A mod_r() 0 3 1
A mod_g() 0 3 1
A mod_b() 0 3 1
A mod_h() 0 3 1
A mod_s() 0 3 1
A mod_l() 0 3 1
A get_scheme() 0 10 3
A get_hex_scheme() 0 3 1
1
<?php
2
3
4
namespace projectcleverweb\color;
5
6
7
class main {
8
	
9
	public $data;
10
	
11
	public function __construct($color) {
12
		$this->set($color);
13
	}
14
	
15
	public function set($color) {
16
		if ($color instanceof data) {
17
			$this->data = $color;
18
		} else {
19
			$this->data = new data($color);
20
		}
21
	}
22
	
23
	public function is_dark(int $check_score = 128) :bool {
24
		$rgb = $this->data->rgb;
0 ignored issues
show
Bug introduced by
The property rgb cannot be accessed from this context as it is declared private in class projectcleverweb\color\data.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
25
		return check::is_dark($rgb['r'], $rgb['g'], $rgb['b'], $check_score);
26
	}
27
	
28
	public function mod_r(float $adjustment, bool $as_percentage = FALSE,  bool $set_absolute = FALSE) {
29
		return modify::rgb($data, 'red', $adjustment, $as_percentage, $set_absolute);
0 ignored issues
show
Bug introduced by
The variable $data does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
30
	}
31
	
32
	public function mod_g(float $adjustment, bool $as_percentage = FALSE,  bool $set_absolute = FALSE) {
33
		return modify::rgb($data, 'green', $adjustment, $as_percentage, $set_absolute);
0 ignored issues
show
Bug introduced by
The variable $data does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
34
	}
35
	
36
	public function mod_b(float $adjustment, bool $as_percentage = FALSE,  bool $set_absolute = FALSE) {
37
		return modify::rgb($data, 'blue', $adjustment, $as_percentage, $set_absolute);
0 ignored issues
show
Bug introduced by
The variable $data does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
38
	}
39
	
40
	public function mod_h(float $adjustment, bool $as_percentage = FALSE,  bool $set_absolute = FALSE) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
41
		return modify::hsl($data, 'hue', $adjustment, $as_percentage, $set_absolute);
0 ignored issues
show
Bug introduced by
The variable $data does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
42
	}
43
	
44
	public function mod_s(float $adjustment, bool $as_percentage = FALSE,  bool $set_absolute = FALSE) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
45
		return modify::hsl($data, 'saturation', $adjustment, $as_percentage, $set_absolute);
0 ignored issues
show
Bug introduced by
The variable $data does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
46
	}
47
	
48
	public function mod_l(float $adjustment, bool $as_percentage = FALSE,  bool $set_absolute = FALSE) {
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
49
		return modify::hsl($data, 'light', $adjustment, $as_percentage, $set_absolute);
0 ignored issues
show
Bug introduced by
The variable $data does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
50
	}
51
	
52
	public function get_scheme(string $scheme_name = '') {
53
		if (is_callable(array(__NAMESPACE__.'\\scheme', $scheme_name))) {
54
			$hsl = $this->hsl->hsl;
0 ignored issues
show
Bug introduced by
The property hsl does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
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