<?php
declare(strict_types=1);

namespace App\Model\Entity;

use Cake\ORM\Entity;

class Program extends Entity
{
    protected array $_accessible = [
        'slug' => true,
        'label' => true,
        'headline' => true,
        'body' => true,
        'bullets' => true,
        'tone' => true,
        'image_path' => true,
        'vessel_type' => true,
        'sort_order' => true,
        'created' => true,
        'modified' => true,
    ];

    /**
     * @return list<string>
     */
    public function getBulletList(): array
    {
        $raw = (string)($this->bullets ?? '');
        $lines = array_map('trim', preg_split('/\r?\n/', $raw) ?: []);

        return array_values(array_filter($lines, static fn ($line) => $line !== ''));
    }
}
