trypost/app/Enums/Ai/ContentStyle.php
Paulo Castellano 9f5bacc03f refactor(ai): introduce GeneratorFormat enum and drop stringly-typed format
Replace the 'single'/'carousel' string format threaded through the AI
generation path with a typed GeneratorFormat enum (PostContentGenerator,
PostContentHumanizer, PostContentStreamer, StreamPostCreation,
RunGenerateNode, deriveFormat).

Remove generatorFormat() from AiContentTemplate and the three templates —
it conflated style and format (returning 'tweet_card'). The tweet-card
check now lives on ContentStyle via isTweetCard(), and the humanizer skip
on ContentStyle::humanizes(), so the style declares its own behaviour
instead of callers comparing magic strings.
2026-06-18 11:11:23 -03:00

66 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Enums\Ai;
enum ContentStyle: string
{
case ImageCard = 'image_card';
case TweetCard = 'tweet_card';
case TweetCardImage = 'tweet_card_image';
/** i18n key for the style's display name. */
public function label(): string
{
return "posts.ai.templates.{$this->value}.name";
}
/** i18n key for the style's description. */
public function description(): string
{
return "posts.ai.templates.{$this->value}.description";
}
/** Whether this style requires a connected social account. */
public function needsAccount(): bool
{
return match ($this) {
self::ImageCard => false,
self::TweetCard, self::TweetCardImage => true,
};
}
/** Whether this style's generated text is run through the humanizer pass. */
public function humanizes(): bool
{
return match ($this) {
self::ImageCard => true,
self::TweetCard, self::TweetCardImage => false,
};
}
/** Whether this style renders the post as a tweet-style card. */
public function isTweetCard(): bool
{
return match ($this) {
self::TweetCard, self::TweetCardImage => true,
self::ImageCard => false,
};
}
/** Public path to the picker preview thumbnail. */
public function previewAsset(): string
{
return match ($this) {
self::ImageCard => '/images/ai-templates/image-card.png',
self::TweetCard => '/images/ai-templates/tweet-card.png',
self::TweetCardImage => '/images/ai-templates/tweet-card-image.png',
};
}
public static function default(): self
{
return self::ImageCard;
}
}