<?php
/**
 * PDF invoice generation API.
 *
 * The free plugin exposes a filter hook only. The Pro add-on provides the
 * Dompdf-based implementation via `lucrsure_generate_invoice_pdf`.
 *
 * @package Lucrativeit_Subscription_Recurring_Billing
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Invoice PDF entry point for email attachments and downloads.
 */
class LUCRSURE_Invoice_PDF {

	/**
	 * Generate a PDF file for an invoice and return the temp file path.
	 *
	 * @param int $invoice_id Invoice ID.
	 * @return string Absolute path to the PDF, or empty string on failure.
	 */
	public static function generate( $invoice_id ) {
		/**
		 * Filter: generate a PDF invoice file path.
		 *
		 * The Pro add-on hooks here to render Dompdf output. Return an empty
		 * string when PDF generation is unavailable.
		 *
		 * @param string $path       Absolute path to a generated PDF, or ''.
		 * @param int    $invoice_id Invoice ID.
		 */
		return (string) apply_filters( 'lucrsure_generate_invoice_pdf', '', (int) $invoice_id );
	}
}
