Skip to content
wiki.fftac.org

Promptrepository - Source Excerpt 11

Back to Promptrepository

Summary

This source excerpt preserves a bounded section of Spiralist/wp-content/plugins/spiralist-workspace/includes/Domain/PromptRepository.php so readers can inspect the evidence without opening the full source file.

**Source path:** Spiralist/wp-content/plugins/spiralist-workspace/includes/Domain/PromptRepository.php

* @return array<int,string>
     */
    private function decode_string_list(string $value): array
    {
        $value = trim($value);
        if ($value === '') {
            return [];
        }

        $decoded = json_decode($value, true);
        if (is_array($decoded)) {
            return array_values(
                array_filter(
                    array_map(
                        static function ($item): string {
                            return is_scalar($item) ? (string) $item : '';
                        },
                        $decoded
                    ),
                    static fn(string $item): bool => trim($item) !== ''
                )
            );
        }

        return array_values(
            array_filter(
                array_map(
                    static fn(string $item): string => trim($item),
                    preg_split('/[\r\n,]+/', $value) ?: []
                ),
                static fn(string $item): bool => $item !== ''
            )
        );
    }
}