<?php

/**
 * PHP-IR boolean literal expression.
 */
final class PhpIrBoolLiteral
{
    private int $startLine;
    private int $endLine;
    private array $comments;
    private bool $value;

    /**
     * Create a boolean literal.
     */
    public function __construct(int $startLine, int $endLine, array $comments, bool $value)
    {
        $this->startLine = $startLine;
        $this->endLine = $endLine;
        $this->comments = $comments;
        $this->value = $value;
    }

    /**
     * Convert to a plain array for debugging/export.
     */
    public function toArray(): array
    {
        return [
            'kind' => 'BoolLiteral',
            'startLine' => $this->startLine,
            'endLine' => $this->endLine,
            'comments' => array_map(static fn (PhpIrComment $comment): array => $comment->toArray(), $this->comments),
            'value' => $this->value,
        ];
    }
}
