Skip to content

Commit 86184b5

Browse files
committed
refactor: better formatting
1 parent ac50aa5 commit 86184b5

File tree

1 file changed

+53
-10
lines changed

1 file changed

+53
-10
lines changed

phpmyfaq/src/phpMyFAQ/Mail.php

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ private function setEmailTo(array &$target, string $targetAlias, string $address
261261
$keys = array_keys($target);
262262
throw new Exception(
263263
sprintf('Too many e-mail addresses, %s, ', $keys[0])
264-
. sprintf(format: "have been already added as '%s'!", values: $targetAlias),
264+
. sprintf(
265+
format: "have been already added as '%s'!",
266+
values: $targetAlias,
267+
),
265268
);
266269
}
267270

@@ -292,20 +295,37 @@ private function addEmailTo(array &$target, string $targetAlias, string $address
292295

293296
if (isset($name)) {
294297
// Remove CR and LF characters to prevent header injection
295-
$name = str_replace(search: ["\n", "\r"], replace: '', subject: $name);
298+
$name = str_replace(
299+
search: ["\n", "\r"],
300+
replace: '',
301+
subject: $name,
302+
);
296303

297304
// Encode any special characters in the displayed name
298305
$name = iconv_mime_encode($targetAlias, $name);
299306

300307
// Wrap the displayed name in quotes (to fix problems with commas etc.),
301308
// and escape any existing quotes
302-
$name = '"' . str_replace(search: '"', replace: '\"', subject: $name) . '"';
309+
$name =
310+
'"'
311+
. str_replace(
312+
search: '"',
313+
replace: '\"',
314+
subject: $name,
315+
)
316+
. '"';
303317
}
304318

305319
// Add the email address into the target array
306320
$target[$address] = $name;
307321
// On Windows, when using PHP built-in mail drops any name, just use the e-mail address
308-
if ('WIN' !== strtoupper(substr(string: PHP_OS, offset: 0, length: 3))) {
322+
if (
323+
'WIN' !== strtoupper(substr(
324+
string: PHP_OS,
325+
offset: 0,
326+
length: 3,
327+
))
328+
) {
309329
return true;
310330
}
311331

@@ -332,7 +352,13 @@ public static function validateEmail(string $address): bool
332352
}
333353

334354
$unsafe = ["\r", "\n"];
335-
if ($address !== str_replace(search: $unsafe, replace: '', subject: $address)) {
355+
if (
356+
$address !== str_replace(
357+
search: $unsafe,
358+
replace: '',
359+
subject: $address,
360+
)
361+
) {
336362
return false;
337363
}
338364

@@ -408,7 +434,10 @@ public function send(): int
408434
$to[] = (empty($name) ? '' : $name . ' ') . '<' . $address . '>';
409435
}
410436

411-
$recipients = implode(separator: ',', array: $to);
437+
$recipients = implode(
438+
separator: ',',
439+
array: $to,
440+
);
412441
// Check for the need of undisclosed recipients outlook-like <TO:>
413442
if (($recipients === '' || $recipients === '0') && 0 === count($this->cc)) {
414443
$recipients = '<Undisclosed-Recipient:;>';
@@ -469,7 +498,10 @@ private function createHeaders(): void
469498
$notifyTos[] = (empty($name) ? '' : $name . ' ') . '<' . $address . '>';
470499
}
471500

472-
$notifyTo = implode(separator: ',', array: $notifyTos);
501+
$notifyTo = implode(
502+
separator: ',',
503+
array: $notifyTos,
504+
);
473505
if ($notifyTo !== '' && $notifyTo !== '0') {
474506
$this->headers['Disposition-Notification-To'] = $notifyTo;
475507
}
@@ -549,7 +581,10 @@ private function createHeaders(): void
549581
*/
550582
public static function getDate(int $date): string
551583
{
552-
return date(format: 'r', timestamp: $date);
584+
return date(
585+
format: 'r',
586+
timestamp: $date,
587+
);
553588
}
554589

555590
/**
@@ -685,7 +720,11 @@ public function fixEOL(string $text): string
685720
subject: $text,
686721
);
687722
// Set any LF to the RFC 2822 EOL
688-
return str_replace(search: "\n", replace: $this->eol, subject: $text);
723+
return str_replace(
724+
search: "\n",
725+
replace: $this->eol,
726+
subject: $text,
727+
);
689728
}
690729

691730
/**
@@ -696,7 +735,11 @@ public function fixEOL(string $text): string
696735
*/
697736
public static function getMUA(string $mua): Builtin|Smtp
698737
{
699-
$className = ucfirst(str_replace(search: '-', replace: '', subject: $mua));
738+
$className = ucfirst(str_replace(
739+
search: '-',
740+
replace: '',
741+
subject: $mua,
742+
));
700743
$class = 'phpMyFAQ\Mail\\' . $className;
701744

702745
return new $class();

0 commit comments

Comments
 (0)