<?php

declare(strict_types=1);

namespace App\Framework\Svg\Builder;

use App\Framework\Core\ValueObjects\Dimensions;
use App\Framework\Filesystem\FileStorage;
use App\Framework\Svg\ValueObjects\Geometry\ViewBox;

/**
 * Static factory for creating SVG canvases
 * Entry point for SVG generation
 */
final class SvgBuilder
{
    /**
     * Create canvas with dimensions
     */
    public static function canvas(
        Dimensions $dimensions,
        ?ViewBox $viewBox = null,
        ?FileStorage $fileStorage = null
    ): SvgCanvas {
        return new SvgCanvas($dimensions, $viewBox, null, null, $fileStorage);
    }

    /**
     * Create canvas from width and height
     */
    public static function create(int $width, int $height, ?FileStorage $fileStorage = null): SvgCanvas
    {
        return new SvgCanvas(new Dimensions($width, $height), null, null, null, $fileStorage);
    }

    /**
     * Create square canvas
     */
    public static function square(int $size, ?FileStorage $fileStorage = null): SvgCanvas
    {
        return new SvgCanvas(new Dimensions($size, $size), null, null, null, $fileStorage);
    }

    /**
     * Create canvas with responsive viewBox
     */
    public static function responsive(int $width, int $height, ?FileStorage $fileStorage = null): SvgCanvas
    {
        $dimensions = new Dimensions($width, $height);
        $viewBox = ViewBox::fromDimensions($dimensions);

        return new SvgCanvas($dimensions, $viewBox, null, null, $fileStorage);
    }

    /**
     * Common canvas sizes
     */
    public static function icon(int $size = 24, ?FileStorage $fileStorage = null): SvgCanvas
    {
        return self::square($size, $fileStorage);
    }

    public static function badge(int $width = 100, int $height = 20, ?FileStorage $fileStorage = null): SvgCanvas
    {
        return self::create($width, $height, $fileStorage);
    }

    public static function card(int $width = 400, int $height = 300, ?FileStorage $fileStorage = null): SvgCanvas
    {
        return self::create($width, $height, $fileStorage);
    }

    public static function chart(int $width = 600, int $height = 400, ?FileStorage $fileStorage = null): SvgCanvas
    {
        return self::responsive($width, $height, $fileStorage);
    }
}
