Passed
Pull Request — master (#11)
by Anton
03:24
created

Captcha   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 0 30 1
1
<?php
2
3
namespace Modules\Tools\Handler {
4
5
	use Frames, Modules\Tools, Utils\Security;
6
7
	class Captcha extends Frames\Tools\Captcha {
8
9
		# Handle request
10
11
		protected function handle() {
12
13
			# Generate capctha code
14
15
			$code = Security::generateCaptcha();
16
17
			# Preset colors
18
19
			$black = [0, 0, 0]; $white = [255, 255, 255];
20
21
			# Create captcha
22
23
			$captcha = new Tools\Captcha(CONFIG_CAPTCHA_WIDTH, CONFIG_CAPTCHA_HEIGHT, $white);
24
25
			# Customize captcha
26
27
			$font = (DIR_SYSTEM_DATA . CONFIG_CAPTCHA_FONT); $size = CONFIG_CAPTCHA_FONT_SIZE;
28
29
			$indent = CONFIG_CAPTCHA_TEXT_INDENT; $step = CONFIG_CAPTCHA_TEXT_STEP;
30
31
			$captcha->text($font, $size, $indent, $step, $code, $black);
32
33
			$captcha->lines(2, $white); $captcha->noise(10, $white);
34
35
			$captcha->lines(2, $black); $captcha->noise(100, $black);
36
37
			# ------------------------
38
39
			return $captcha;
40
		}
41
	}
42
}
43