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

Captcha::handle()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
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