Passed
Push — master ( a357e7...195a07 )
by Anton
04:22 queued 01:11
created

Controller   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B __invoke() 0 26 4
1
<?php
2
3
namespace Addons\Contact {
4
5
	use Modules\Auth, Modules\Settings, Utils\Security, Utils\Validate, Mailer;
6
7
	class Controller {
8
9
		# Invoker
10
11
		public function __invoke(array $post) {
12
13
			# Declare variables
14
15
			$name = ''; $email = ''; $message = ''; $captcha = '';
16
17
			# Extract post array
18
19
			extract($post);
20
21
			# Validate values
22
23
			if (false === ($email = Validate::userEmail($email))) return ['email', 'CONTACT_ERROR_EMAIL_INVALID'];
24
25
			if (false === Security::checkCaptcha($captcha)) return ['captcha', 'CONTACT_ERROR_CAPTCHA_INCORRECT'];
26
27
			# Send mail
28
29
			$to = Settings::get('system_email'); $subject = (Settings::get('site_title') . ' | Contact form message');
30
31
			if (!Mailer::send($to, $name, $email, $email, $subject, $message)) return 'CONTACT_ERROR_SEND';
32
33
			# ------------------------
34
35
			return true;
36
		}
37
	}
38
}
39