prepare( 'SELECT id, title, slug, short_description, full_description, image, badge, technologies, project_url, display_order, created_at FROM projects WHERE status = :status ORDER BY display_order ASC, created_at DESC' ); $stmt->execute(['status' => 'published']); return $stmt->fetchAll(); } catch (PDOException $e) { error_log('[Portfolio] Erreur récupération projets : ' . $e->getMessage()); return []; } catch (Throwable $e) { error_log('[Portfolio] Erreur inattendue projets : ' . $e->getMessage()); return []; } } /** * Formate le badge d'état pour l'affichage * * @param string $badge 'development' ou 'production' * @return array ['label' => string, 'class' => string] */ function formatBadge(string $badge): array { return match ($badge) { 'production' => ['label' => 'En production', 'class' => 'badge--production'], 'development' => ['label' => 'En développement', 'class' => 'badge--development'], default => ['label' => 'En cours', 'class' => 'badge--development'], }; } /** * Transforme la chaîne de technologies en tableau * * @param string|null $technologies Chaîne séparée par des virgules * @return array */ function parseTechnologies(?string $technologies): array { if (empty($technologies)) { return []; } return array_map('trim', explode(',', $technologies)); }