Publication initiale de RelaisSMS : documentation et sources nettoyees
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Sms;
|
||||
|
||||
use App\Models\AppSetting;
|
||||
|
||||
class SmsMessageComposer
|
||||
{
|
||||
/**
|
||||
* @return array{header: string, footer: string}
|
||||
*/
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'header' => AppSetting::string('sms_message_header'),
|
||||
'footer' => AppSetting::string('sms_message_footer'),
|
||||
];
|
||||
}
|
||||
|
||||
public function compose(string $body, bool $includeHeader = true, bool $includeFooter = true): string
|
||||
{
|
||||
$settings = $this->settings();
|
||||
$parts = [];
|
||||
|
||||
if ($includeHeader && $settings['header'] !== '') {
|
||||
$parts[] = $settings['header'];
|
||||
}
|
||||
|
||||
if (trim($body) !== '') {
|
||||
$parts[] = trim($body);
|
||||
}
|
||||
|
||||
if ($includeFooter && $settings['footer'] !== '') {
|
||||
$parts[] = $settings['footer'];
|
||||
}
|
||||
|
||||
return implode("\n", $parts);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user