<?php

namespace WcElectronInvoice\Providers;

defined( 'ABSPATH' ) || die( 'Not allowed.' );

class TaxesQuery {

	protected static $instance;

	/**
	 * Return a single instance
	 *
	 * @return TaxesQuery
	 */
	public static function instance() {
		if ( ! isset( self::$instance ) ) {
			self::$instance = new TaxesQuery();
		}

		return self::$instance;
	}


	/**
	 * @var TaxProviderAbstract[]
	 */
	protected $taxProviders = [];

	/**
	 * Get tax provider by its key
	 *
	 * @param $provider_name
	 *
	 * @return TaxProviderAbstract
	 */
	public function getTaxProvider( $provider_name ) {
		return $this->taxProviders[ $provider_name ] ?? null;
	}

	/**
	 * Register a products provider
	 *
	 * @param TaxProviderAbstract $provider
	 *
	 * @return void
	 */
	public function register_provider( TaxProviderAbstract $provider ) {
		$this->taxProviders[ $provider->name() ] = $provider;
	}

}
