<?php
declare(strict_types=1);

namespace App\Framework\Math;

use Stringable;

final readonly class Number implements Stringable
{
    public string $value;
    public function __construct(
        string|int $value,
        public Context $context = new Context,
        private NumberCalculator $calculator = new NumberCalculator,
    ) {
        $this->value = (string)$value;
    }

    public function add(Number $number, ?Context $context = null): self
    {
        return $this->calculator->add($this, $number, $context ?? $this->context);
    }

    public function subtract(Number $number, ?Context $context = null): self
    {
        return $this->calculator->subtract($this, $number, $context ?? $this->context);
    }

    public function multiply(Number $number, ?Context $context = null): self
    {
        return $this->calculator->multiply($this, $number, $context ?? $this->context);
    }

    public function divide(Number $number, ?Context $context = null): self
    {
        return $this->calculator->divide($this, $number, $context ?? $this->context);
    }



    public function equal(Number $number, ?Context $context = null): self
    {
        return $this->calculator->add($this, $number, $context ?? $this->context);
    }

    public function greaterThan(Number $number, ?Context $context = null): self
    {
        return $this->calculator->add($this, $number, $context ?? $this->context);
    }

    public function greaterThanOrEqual(Number $number, ?Context $context = null): self
    {
        return $this->calculator->add($this, $number, $context ?? $this->context);
    }

    public function lessThan(Number $number, ?Context $context = null): self
    {
        return $this->calculator->add($this, $number, $context ?? $this->context);
    }

    public function lessThanOrEqual(Number $number, ?Context $context = null): self
    {
        return $this->calculator->add($this, $number, $context ?? $this->context);
    }

    public function format(
        ?Context $context = null,
        string $decimalSeparator = '',
        string $thousandSeparator = '',
    ):string {
        return $this->value;
    }

    public function __toString()
    {
        return $this->value;
    }
}
