<?php

namespace Api\PhpServices\Printer;

/**
 *  打印工厂类
 *
 * 如何使用：
 * $content = [['aaa'], 'bbb'];
 * $FeiPrinter = PrinterFactory::getPrinter('Fei');
 * $res = $FeiPrinter->printContent('921617329', $content);
 * $res = $FeiPrinter->getOrderStatus('921617329_20210725143642_699302110');
 * $res = $FeiPrinter->getPrinterStatus('921617329');
 * @author mengweifu
 * @date 2021-7-25 14:00:00
 */
class PrinterFactory
{

    /**
     * 获取打印实现类
     * @param string $printerName
     * @return mixed
     * @throws \Exception
     */
    public static function getPrinter(string $printerName) : Printer
    {
        if (! file_exists(__DIR__ .DIRECTORY_SEPARATOR. $printerName. DIRECTORY_SEPARATOR . $printerName . 'Printer.php')) {
            throw  new \Exception("相应printer未找到");
        }
        $printerClass = "Api\\PhpServices\\Printer\\${printerName}\\${printerName}Printer";
        return new $printerClass;
    }
}