Conditions | 6 |
Paths | 2 |
Total Lines | 56 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
67 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
68 | { |
||
69 | $mail_ssl_options = $this->email_service->mailSslOptions(); |
||
70 | $mail_transport_options = $this->email_service->mailTransportOptions(); |
||
71 | |||
72 | $title = I18N::translate('Sending email'); |
||
73 | |||
74 | $SMTP_ACTIVE = Site::getPreference('SMTP_ACTIVE'); |
||
75 | $SMTP_AUTH = Site::getPreference('SMTP_AUTH'); |
||
76 | $SMTP_AUTH_USER = Site::getPreference('SMTP_AUTH_USER'); |
||
77 | $SMTP_DISP_NAME = Site::getPreference('SMTP_DISP_NAME'); |
||
78 | $SMTP_FROM_NAME = Site::getPreference('SMTP_FROM_NAME'); |
||
79 | $SMTP_HELO = Site::getPreference('SMTP_HELO'); |
||
80 | $SMTP_HOST = Site::getPreference('SMTP_HOST'); |
||
81 | $SMTP_PORT = Site::getPreference('SMTP_PORT'); |
||
82 | $SMTP_SSL = Site::getPreference('SMTP_SSL'); |
||
83 | $DKIM_DOMAIN = Site::getPreference('DKIM_DOMAIN'); |
||
84 | $DKIM_SELECTOR = Site::getPreference('DKIM_SELECTOR'); |
||
85 | $DKIM_KEY = Site::getPreference('DKIM_KEY'); |
||
86 | |||
87 | try { |
||
88 | $hostname = gethostbyaddr(gethostbyname(gethostname())); |
||
89 | } catch (Throwable $ex) { |
||
90 | $hostname = 'localhost'; |
||
91 | } |
||
92 | |||
93 | // Defaults |
||
94 | $SMTP_PORT = $SMTP_PORT ?: '25'; |
||
95 | $SMTP_HELO = $SMTP_HELO ?: $hostname; |
||
96 | $SMTP_FROM_NAME = $SMTP_FROM_NAME ?: ('no-reply@' . $SMTP_HELO); |
||
97 | $SMTP_DISP_NAME = $SMTP_DISP_NAME ?: Webtrees::NAME; |
||
98 | |||
99 | |||
100 | $smtp_from_name_valid = $this->email_service->isValidEmail($SMTP_FROM_NAME); |
||
101 | $smtp_helo_valid = filter_var($SMTP_HELO, FILTER_VALIDATE_DOMAIN); |
||
102 | |||
103 | $this->layout = 'layouts/administration'; |
||
104 | |||
105 | return $this->viewResponse('admin/site-mail', [ |
||
106 | 'mail_ssl_options' => $mail_ssl_options, |
||
107 | 'mail_transport_options' => $mail_transport_options, |
||
108 | 'title' => $title, |
||
109 | 'smtp_helo_valid' => $smtp_helo_valid, |
||
110 | 'smtp_from_name_valid' => $smtp_from_name_valid, |
||
111 | 'SMTP_ACTIVE' => $SMTP_ACTIVE, |
||
112 | 'SMTP_AUTH' => $SMTP_AUTH, |
||
113 | 'SMTP_AUTH_USER' => $SMTP_AUTH_USER, |
||
114 | 'SMTP_DISP_NAME' => $SMTP_DISP_NAME, |
||
115 | 'SMTP_FROM_NAME' => $SMTP_FROM_NAME, |
||
116 | 'SMTP_HELO' => $SMTP_HELO, |
||
117 | 'SMTP_HOST' => $SMTP_HOST, |
||
118 | 'SMTP_PORT' => $SMTP_PORT, |
||
119 | 'SMTP_SSL' => $SMTP_SSL, |
||
120 | 'DKIM_DOMAIN' => $DKIM_DOMAIN, |
||
121 | 'DKIM_SELECTOR' => $DKIM_SELECTOR, |
||
122 | 'DKIM_KEY' => $DKIM_KEY, |
||
123 | ]); |
||
126 |