<?php

namespace PloverCRM\Core\CRM\Schemas;

/**
 * Column Schema
 * 
 * Defines the standard structure for column data
 * Legacy format: Simple array of column names
 */
class ColumnSchema
{
    /**
     * Validate columns data
     * 
     * @param array $data
     * @return array
     */
    public static function validate(array $data): array
    {
        $errors = [];

        // Should be a simple indexed array of strings
        if (!is_array($data)) {
            $errors[] = "Columns must be an array";
        } else {
            foreach ($data as $index => $column) {
                if (!is_string($column)) {
                    $errors[] = "Column at index {$index} must be a string";
                }
            }
        }

        return [
            'valid' => empty($errors),
            'errors' => $errors,
        ];
    }

    /**
     * Normalize columns data
     * 
     * @param array $data
     * @return array
     */
    public static function normalize(array $data): array
    {
        // Ensure all values are strings
        return array_map('strval', array_values($data));
    }
}
