Captcha::_main()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 2
nop 0
1
<?php
2
3
/**
4
 * @package Cadmium\System\Frames
5
 * @author Anton Romanov
6
 * @copyright Copyright (c) 2015-2017, Anton Romanov
7
 * @link http://cadmium-cms.com
8
 */
9
10
namespace Frames\Tools {
11
12
	use Frames, Modules\Tools, Exception, Image;
13
14
	abstract class Captcha extends Frames\Main {
15
16
		/**
17
		 * The branch method for the captcha
18
		 */
19
20
		protected function _main() {
21
22
			$captcha = $this->handle();
23
24
			if (($captcha instanceof Tools\Captcha) && (null !== $captcha->image())) {
25
26
				return Image::outputPNG($captcha->image());
27
			}
28
29
			# ------------------------
30
31
			throw new Exception\Captcha;
32
		}
33
34
		/**
35
		 * The interface for a handler method
36
		 *
37
		 * @return Frames\Tools\Captcha|null : the captcha object on success or null on failure
38
		 */
39
40
		abstract protected function handle();
41
	}
42
}
43