1 | <?php |
||
29 | abstract class PaymentSlipPdf |
||
30 | { |
||
31 | /** |
||
32 | * The PDF engine object to generate the PDF output |
||
33 | * |
||
34 | * @var null|object |
||
35 | */ |
||
36 | protected $pdfEngine = null; |
||
37 | |||
38 | /** |
||
39 | * The payment slip object, which contains the payment slip data and layout information |
||
40 | * |
||
41 | * @var null|PaymentSlip |
||
42 | */ |
||
43 | protected $paymentSlip = null; |
||
44 | |||
45 | /** |
||
46 | * Create a new object to create Swiss payment slips as PDFs |
||
47 | * |
||
48 | * @param object $pdfEngine The PDF engine object to generate the PDF output. |
||
49 | * which contains the payment slip data and layout information. |
||
50 | */ |
||
51 | 2 | public function __construct($pdfEngine) |
|
52 | { |
||
53 | 2 | if (!is_object($pdfEngine)) { |
|
54 | 1 | throw new \InvalidArgumentException('$pdfEngine is not an object!'); |
|
55 | } |
||
56 | 1 | $this->pdfEngine = $pdfEngine; |
|
57 | 1 | } |
|
58 | |||
59 | /** |
||
60 | * Display a background image |
||
61 | * |
||
62 | * Implement this method by using the parameter(s) with he appropriate method of the PDF engine. |
||
63 | * |
||
64 | * @param string $background The background image path. |
||
65 | * @return $this The current instance for a fluent interface. |
||
66 | */ |
||
67 | abstract protected function displayImage($background); |
||
68 | |||
69 | /** |
||
70 | * Set the font of an element |
||
71 | * |
||
72 | * Implement this method by using the parameter(s) with he appropriate method of the PDF engine. |
||
73 | * |
||
74 | * @param string $fontFamily The font family |
||
75 | * @param int|float $fontSize The font size. |
||
76 | * @param string $fontColor The font color. Either the name of the color or its RGB hex code. |
||
77 | * @return $this The current instance for a fluent interface. |
||
78 | */ |
||
79 | abstract protected function setFont($fontFamily, $fontSize, $fontColor); |
||
80 | |||
81 | /** |
||
82 | * Set the background of an element |
||
83 | * |
||
84 | * Implement this method by using the parameter(s) with he appropriate method of the PDF engine. |
||
85 | * |
||
86 | * @param $background |
||
87 | * @return $this The current instance for a fluent interface. |
||
88 | */ |
||
89 | abstract protected function setBackground($background); |
||
90 | |||
91 | /** |
||
92 | * Set the position of an element |
||
93 | * |
||
94 | * Implement this method by using the parameter(s) with he appropriate method of the PDF engine. |
||
95 | * |
||
96 | * @param int|float $posX The X position. |
||
97 | * @param int|float $posY The Y position. |
||
98 | * @return $this The current instance for a fluent interface. |
||
99 | */ |
||
100 | abstract protected function setPosition($posX, $posY); |
||
101 | |||
102 | /** |
||
103 | * Create the element cell using the PDF engine |
||
104 | * |
||
105 | * Implement this method by using the parameter(s) with he appropriate method of the PDF engine. |
||
106 | * |
||
107 | * @param int|float $width The width. |
||
108 | * @param int|float $height The height. |
||
109 | * @param string $line The text/content of the line. |
||
110 | * @param string $textAlign The text alignment. |
||
111 | * @param bool $fill Whether to fill the background of the cell. |
||
112 | * @return $this The current instance for a fluent interface. |
||
113 | */ |
||
114 | abstract protected function createCell($width, $height, $line, $textAlign, $fill); |
||
115 | |||
116 | /** |
||
117 | * Write the lines of an element to the PDf |
||
118 | * |
||
119 | * @param string $elementName The name of the element. |
||
120 | * @param array $element The element. |
||
121 | * @return $this The current instance for a fluent interface. |
||
122 | */ |
||
123 | 7 | protected function writePaymentSlipLines($elementName, array $element) |
|
173 | |||
174 | /** |
||
175 | * Create a payment slip as a PDF using the PDF engine |
||
176 | * |
||
177 | * @param PaymentSlip $paymentSlip The payment slip to create as PDF. |
||
178 | * @return $this The current instance for a fluent interface. |
||
179 | */ |
||
180 | 2 | public function createPaymentSlip(PaymentSlip $paymentSlip) |
|
200 | } |
||
201 |