forked from fa/breadcrumb-the-shire
Rename the top-level lib/ directory to core/ so the project root immediately communicates which code is core platform and which lives in modules/. PHP namespaces (MintyPHP\*) are unchanged — only the Composer PSR-4 path mapping moves from lib/ to core/. Module-internal lib/ directories (modules/*/lib/) are untouched. Updated across the full stack: - composer.json PSR-4 mapping - bootstrap entry points (web/index.php, bin/*, tests/bootstrap.php) - tooling configs (phpstan.neon, phpunit.xml, php-cs-fixer) - 26 architecture contract tests - enforcement-policy, guard-catalog, quality-gates - all documentation (CLAUDE.md, README, 25 docs/, .agents/skills/) - bin/qa-extended.sh search paths - .claude/settings.local.json permission paths Workflow: .agents/runs/CORE-LIB-RENAME-001/ (Analyst → Planner → Executor → Code Review (4 findings fixed) → Security Review → Acceptance Test → Finalizer) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
143 lines
4.6 KiB
PHP
143 lines
4.6 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Service\Settings;
|
|
|
|
class SettingsSmtpGateway
|
|
{
|
|
public function __construct(private readonly SettingsMetadataGateway $settingsMetadataGateway)
|
|
{
|
|
}
|
|
|
|
public function getSmtpHost(): ?string
|
|
{
|
|
$value = $this->settingsMetadataGateway->getValue(SettingKeys::SMTP_HOST_KEY);
|
|
$value = $value !== null ? trim($value) : '';
|
|
return $value !== '' ? $value : null;
|
|
}
|
|
|
|
public function setSmtpHost(?string $host, ?string $description = null): bool
|
|
{
|
|
$value = $host !== null ? trim($host) : '';
|
|
if ($value === '') {
|
|
$value = null;
|
|
}
|
|
|
|
$desc = $description ?? 'setting.smtp_host';
|
|
return $this->settingsMetadataGateway->set(SettingKeys::SMTP_HOST_KEY, $value, $desc);
|
|
}
|
|
|
|
public function getSmtpPort(): ?int
|
|
{
|
|
$value = $this->settingsMetadataGateway->getValue(SettingKeys::SMTP_PORT_KEY);
|
|
if ($value === null || $value === '') {
|
|
return null;
|
|
}
|
|
|
|
$port = (int) $value;
|
|
return $port > 0 ? $port : null;
|
|
}
|
|
|
|
public function setSmtpPort(?int $port, ?string $description = null): bool
|
|
{
|
|
$value = $port && $port > 0 ? (string) $port : null;
|
|
$desc = $description ?? 'setting.smtp_port';
|
|
return $this->settingsMetadataGateway->set(SettingKeys::SMTP_PORT_KEY, $value, $desc);
|
|
}
|
|
|
|
public function getSmtpUser(): ?string
|
|
{
|
|
$value = $this->settingsMetadataGateway->getValue(SettingKeys::SMTP_USER_KEY);
|
|
$value = $value !== null ? trim($value) : '';
|
|
return $value !== '' ? $value : null;
|
|
}
|
|
|
|
public function setSmtpUser(?string $user, ?string $description = null): bool
|
|
{
|
|
$value = $user !== null ? trim($user) : '';
|
|
if ($value === '') {
|
|
$value = null;
|
|
}
|
|
|
|
$desc = $description ?? 'setting.smtp_user';
|
|
return $this->settingsMetadataGateway->set(SettingKeys::SMTP_USER_KEY, $value, $desc);
|
|
}
|
|
|
|
public function getSmtpPassword(): ?string
|
|
{
|
|
$value = $this->settingsMetadataGateway->getValue(SettingKeys::SMTP_PASSWORD_KEY);
|
|
$value = $value !== null ? (string) $value : '';
|
|
return $value !== '' ? $value : null;
|
|
}
|
|
|
|
public function setSmtpPassword(?string $password, ?string $description = null): bool
|
|
{
|
|
$value = $password !== null ? (string) $password : '';
|
|
if ($value === '') {
|
|
$value = null;
|
|
}
|
|
|
|
$desc = $description ?? 'setting.smtp_password';
|
|
return $this->settingsMetadataGateway->set(SettingKeys::SMTP_PASSWORD_KEY, $value, $desc);
|
|
}
|
|
|
|
public function getSmtpSecure(): ?string
|
|
{
|
|
$value = $this->settingsMetadataGateway->getValue(SettingKeys::SMTP_SECURE_KEY);
|
|
$value = $value !== null ? strtolower(trim($value)) : '';
|
|
if (!in_array($value, ['tls', 'ssl', 'none'], true)) {
|
|
return null;
|
|
}
|
|
|
|
return $value === 'none' ? null : $value;
|
|
}
|
|
|
|
public function setSmtpSecure(?string $secure, ?string $description = null): bool
|
|
{
|
|
$value = $secure !== null ? strtolower(trim($secure)) : '';
|
|
if ($value === '' || $value === 'none') {
|
|
$value = null;
|
|
} elseif (!in_array($value, ['tls', 'ssl'], true)) {
|
|
return false;
|
|
}
|
|
|
|
$desc = $description ?? 'setting.smtp_secure';
|
|
return $this->settingsMetadataGateway->set(SettingKeys::SMTP_SECURE_KEY, $value, $desc);
|
|
}
|
|
|
|
public function getSmtpFrom(): ?string
|
|
{
|
|
$value = $this->settingsMetadataGateway->getValue(SettingKeys::SMTP_FROM_KEY);
|
|
$value = $value !== null ? trim($value) : '';
|
|
return $value !== '' ? $value : null;
|
|
}
|
|
|
|
public function setSmtpFrom(?string $from, ?string $description = null): bool
|
|
{
|
|
$value = $from !== null ? trim($from) : '';
|
|
if ($value === '') {
|
|
$value = null;
|
|
}
|
|
|
|
$desc = $description ?? 'setting.smtp_from';
|
|
return $this->settingsMetadataGateway->set(SettingKeys::SMTP_FROM_KEY, $value, $desc);
|
|
}
|
|
|
|
public function getSmtpFromName(): ?string
|
|
{
|
|
$value = $this->settingsMetadataGateway->getValue(SettingKeys::SMTP_FROM_NAME_KEY);
|
|
$value = $value !== null ? trim($value) : '';
|
|
return $value !== '' ? $value : null;
|
|
}
|
|
|
|
public function setSmtpFromName(?string $fromName, ?string $description = null): bool
|
|
{
|
|
$value = $fromName !== null ? trim($fromName) : '';
|
|
if ($value === '') {
|
|
$value = null;
|
|
}
|
|
|
|
$desc = $description ?? 'setting.smtp_from_name';
|
|
return $this->settingsMetadataGateway->set(SettingKeys::SMTP_FROM_NAME_KEY, $value, $desc);
|
|
}
|
|
}
|