<?php

namespace WPDesk\FakturyKSEF\Dashboard;

class VatRates {

	private function get_vat_types(): array {
		$inspire_invoices_tax = get_option( 'inspire_invoices_tax', [] );
		$rates                = [];
		$index                = 0;
		foreach ( $inspire_invoices_tax as $tax ) {
			$rates[] = [
				'index' => $index,
				'rate'  => $tax['rate'],
				'name'  => $tax['name'],
			];
			++$index;
		}

		return apply_filters( 'inspire_invoices_vat_types', $rates );
	}

	public function get_vat_types_options( string $default_label ): array {
		$vat_types_options     = [];
		$vat_types_options[''] = $default_label;
		$vat_types             = self::get_vat_types();
		foreach ( $vat_types as $vat_type ) {
			$vat_types_options[ $vat_type['index'] ] = $vat_type['name'];
		}

		return $vat_types_options;
	}
}
