<?php

declare(strict_types=1);

namespace App\Framework\Svg\Charts\ValueObjects;

/**
 * Value Object representing a single data point in a chart
 */
final readonly class DataPoint
{
    public function __construct(
        public string $label,
        public float $value
    ) {
    }

    /**
     * Check if value is positive
     */
    public function isPositive(): bool
    {
        return $this->value > 0;
    }

    /**
     * Check if value is negative
     */
    public function isNegative(): bool
    {
        return $this->value < 0;
    }

    /**
     * Check if value is zero
     */
    public function isZero(): bool
    {
        return $this->value === 0.0;
    }

    /**
     * Scale value by factor
     */
    public function scale(float $factor): self
    {
        return new self($this->label, $this->value * $factor);
    }

    public function toArray(): array
    {
        return [
            'label' => $this->label,
            'value' => $this->value,
        ];
    }
}
