<?php

namespace domain\Order\OrderStatusHistory;

use domain\_\AbstractManager;
use domain\Order\Order\Order;
use domain\Order\OrderStatus\OrderStatus;
use domain\User\User\User;

class OrderStatusHistoryManager extends AbstractManager
{
    protected OrderStatusHistoryBuilder $orderStatusHistoryBuilder;

    public function loadDependencies(): void
    {
        $this->orderStatusHistoryBuilder = $this->loadService(OrderStatusHistoryBuilder::class);
    }

    public function create(
        Order $order,
        OrderStatus $orderStatus,
        \DateTime $date,
        User $user
    ): OrderStatusHistory
    {
        $orderStatusHistory = $this->orderStatusHistoryBuilder->instanciateOrderStatusHistory($order, $orderStatus, $date, $user);
        $this->orderStatusHistoryBuilder->create($orderStatusHistory);
        return $orderStatusHistory;
    }
}