<?php

namespace WPDesk\FakturyKSEF\Blocks\Replacers;

use WPDesk\CoreAlias\AbstractBasicReplacer;
use WPDesk\CoreAlias\TemplateDocumentDecorator;

class KSeFQRCodeReplacer extends AbstractBasicReplacer {

	protected function get_wrapper_tags(): array {
		return [
			'start' => 'KSeFQRCodeBegin',
			'end'   => 'KSeFQRCodeEnd',
		];
	}

	protected function get_shortcodes_to_replace( TemplateDocumentDecorator $invoice ): array {
		$shortcode = sprintf( '[fiksef_document_qrcode document_id="%d"]', $invoice->get_id() );
		return [
			'{KSeFDocumentQRCode}' => do_shortcode( $shortcode ),
		];
	}

	public function modify_content( TemplateDocumentDecorator $invoice, string $content ): string {
		$shortcodes = $this->get_shortcodes_to_replace( $invoice );
		return $this->replace_shortcodes( $shortcodes, $content );
	}
}
