Clean code

This commit is contained in:
julien
2026-03-27 22:30:10 +01:00
parent 68c547ddcb
commit 7757628a94
29 changed files with 164 additions and 268 deletions

View File

@@ -133,9 +133,11 @@ class Post extends DB\SQL\Mapper
public function delete(int $id): void
{
$this->load(['id = ?', $id]);
if (!$this->dry()) {
$this->erase();
if ($this->dry()) {
throw new RuntimeException('Article introuvable.');
}
$this->erase();
}
private function payload(array $input): array
@@ -168,7 +170,7 @@ class Post extends DB\SQL\Mapper
}
}
$bodyHtml = MarkdownService::compile($bodyMarkdown, $media);
$bodyHtml = MarkdownService::instance()->compile($bodyMarkdown, $media);
return [
'title' => $title,
@@ -193,10 +195,7 @@ class Post extends DB\SQL\Mapper
'excerpt' => (string) $row['excerpt'],
'cover_media_id' => (int) ($row['cover_media_id'] ?? 0),
'created_at' => (string) $row['created_at'],
'created_at_label' => app_format_datetime_fr((string) $row['created_at']),
'updated_at' => (string) $row['updated_at'],
'updated_at_label' => app_format_datetime_fr((string) $row['updated_at']),
'has_updated_at' => (string) $row['updated_at'] !== (string) $row['created_at'],
];
}