<?php

namespace WPML\Core\Component\Translation\Application\Service\Priority;

use WPML\Core\Component\Translation\Application\Query\Priority\PostDataQueryInterface;
use WPML\Core\Component\Translation\Application\Query\Priority\StringDataQueryInterface;

/**
 * Factory for creating JobPriorityService instances.
 */
class JobPriorityServiceFactory {


    /**
     * Create a JobPriorityService with default configuration.
     *
     * @param PostDataQueryInterface|null   $postDataQuery
     * @param StringDataQueryInterface|null $stringDataQuery
     * @param array<string, int>            $stringDomainPriorities
     * @param array<string, int>            $stringContextPriorities
     * @param array<string, int>            $cptPriorities
     *
     * @return JobPriorityService
     */
  public static function create(
        $postDataQuery = null,
        $stringDataQuery = null,
        array $stringDomainPriorities = [],
        array $stringContextPriorities = [],
        array $cptPriorities = []
    ): JobPriorityService {
      $sorter         = new JobPrioritySorter();
      $contextBuilder = new ClassificationContextBuilder(
        null,
        $stringDomainPriorities,
        $stringContextPriorities,
        $cptPriorities
      );
      $itemBuilder    = new PrioritizableItemBuilder();
      $payloadBuilder = new OrderingPayloadBuilder();

      return new JobPriorityService(
        $sorter,
        $contextBuilder,
        $itemBuilder,
        $payloadBuilder,
        $postDataQuery,
        $stringDataQuery
      );
  }


    /**
     * Create a JobPriorityService with default WordPress integration.
     *
     * @return JobPriorityService
     */
  public static function createDefault(): JobPriorityService {
      return self::create();
  }


}
