$config */ public function issueFor(array $config): ?string { $accounts = data_get($config, 'accounts'); if (! is_array($accounts) || $accounts === []) { return null; } // Single source of truth: 0 = text-only, 1 = single image, 2+ = carousel. $imageCount = (int) data_get($config, 'target_slide_count', 1); foreach ($accounts as $entry) { $contentType = ContentType::tryFrom((string) data_get($entry, 'content_type')); if (! $contentType instanceof ContentType) { continue; } $issue = $this->issueForAccount($contentType, $imageCount); if ($issue !== null) { return $issue; } } return null; } private function issueForAccount(ContentType $contentType, int $imageCount): ?string { if ($contentType->requiresMedia() && $imageCount === 0) { return __('posts.edit.compliance.requires_media'); } if ($imageCount > 0 && ! $contentType->supportsImage()) { return __('posts.edit.compliance.no_images'); } $max = min(self::MAX_GENERATED_IMAGES, $contentType->maxMediaCount()); if ($imageCount > $max) { return __('posts.edit.compliance.too_many_files', ['max' => (string) $max]); } return null; } }