Completed
Push — master ( 416cb1...222de5 )
by Anton
03:44
created

Mail   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6
Metric Value
wmc 6
lcom 0
cbo 6
dl 0
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 14 2
A reset() 0 6 2
A register() 0 6 2
1
<?php
2
3
namespace Modules\Auth\Utils {
4
5
	use Modules\Auth, Modules\Entitizer, Modules\Settings, Utils\View, Date, Language, Mailer;
6
7
	abstract class Mail {
8
9
		# Send mail
10
11
		private static function send(Entitizer\Entity\User $user, string $view, string $subject, string $link) {
12
13
			$message = View::get($view);
14
15
			$message->name = $user->name; $message->link = $link; $message->copyright = Date::year();
0 ignored issues
show
Bug introduced by
The property name does not seem to exist in Modules\Entitizer\Entity\User.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
16
17
			# ------------------------
18
19
			$to = $user->email; $sender = Settings::get('site_title'); $reply_to = Settings::get('system_email');
0 ignored issues
show
Bug introduced by
The property email does not seem to exist in Modules\Entitizer\Entity\User.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
20
21
			$from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@' . $host) : '');
22
23
			return Mailer::send($to, $sender, $from, $reply_to, $subject, $message->contents(true), true);
24
		}
25
26
		# Send reset mail
27
28
		public static function reset(Entitizer\Entity\User $user, string $code) {
29
30
			$link = (Settings::get('system_url') . (Auth::admin() ? '/admin' : '/profile') . '/recover?code=' . $code);
31
32
			return self::send($user, 'Blocks\Auth\Mail\Reset', Language::get('MAIL_SUBJECT_RESET'), $link);
33
		}
34
35
		# Send register mail
36
37
		public static function register(Entitizer\Entity\User $user) {
38
39
			$link = (Settings::get('system_url') . (Auth::admin() ? '/admin' : '/profile'));
40
41
			return self::send($user, 'Blocks\Auth\Mail\Register', Language::get('MAIL_SUBJECT_REGISTER'), $link);
42
		}
43
	}
44
}
45