11<?php namespace CanGelis \PDF ;
22
33use League \Flysystem \AdapterInterface ;
4- use \League \Flysystem \Filesystem ;
4+ use League \Flysystem \Filesystem ;
5+
56class PDF {
67
78 /**
@@ -39,13 +40,13 @@ class PDF {
3940 */
4041 protected $ path = null ;
4142
42- /**
43- * PDF File's Binary content
44- *
45- * @var mixed
46- */
43+ /**
44+ * PDF File's Binary content
45+ *
46+ * @var mixed
47+ */
4748
48- protected $ contents = null ;
49+ protected $ contents = null ;
4950
5051 /**
5152 * Available command parameters for wkhtmltopdf
@@ -84,7 +85,8 @@ public function __construct($cmd, $tmpFolder = null)
8485 if (is_null ($ tmpFolder ))
8586 {
8687 $ this ->folder = sys_get_temp_dir ();
87- } else
88+ }
89+ else
8890 {
8991 $ this ->folder = $ tmpFolder ;
9092 }
@@ -143,7 +145,8 @@ public function generate()
143145 if ($ returnVar == 0 )
144146 {
145147 $ this ->contents = $ this ->getPDFContents ();
146- } else
148+ }
149+ else
147150 {
148151 throw new PDFException ($ output );
149152 }
@@ -157,32 +160,36 @@ public function generate()
157160 /**
158161 * Saves the pdf content to the specified location
159162 *
160- * @param $fileName
161- * @param AdapterInterface $adapter
162- * @param bool $overwrite
163- *
164- * @return $this
163+ * @param $fileName
164+ * @param AdapterInterface $adapter
165+ * @param bool $overwrite
166+ *
167+ * @return $this
165168 */
166169 public function save ($ fileName , AdapterInterface $ adapter , $ overwrite = false )
167170 {
168171 $ fs = new Filesystem ($ adapter );
169172
170- if ($ overwrite == true ) {
171- $ fs ->put ($ fileName , $ this ->get ());
172- } else {
173- $ fs ->write ($ fileName , $ this ->get ());
174- }
173+ if ($ overwrite == true )
174+ {
175+ $ fs ->put ($ fileName , $ this ->get ());
176+ }
177+ else
178+ {
179+ $ fs ->write ($ fileName , $ this ->get ());
180+ }
175181
176- return $ this ;
182+ return $ this ;
177183 }
178184
179- public function get ()
180- {
181- if (is_null ($ this ->contents )) {
182- $ this ->generate ();
183- }
184- return $ this ->contents ;
185- }
185+ public function get ()
186+ {
187+ if (is_null ($ this ->contents ))
188+ {
189+ $ this ->generate ();
190+ }
191+ return $ this ->contents ;
192+ }
186193
187194 /**
188195 * Remove temporary HTML and PDF files
@@ -249,7 +256,8 @@ protected function getParams()
249256 if (is_numeric ($ key ))
250257 {
251258 $ result .= '-- ' . $ value ;
252- } else
259+ }
260+ else
253261 {
254262 $ result .= '-- ' . $ key . ' ' . '" ' . $ value . '" ' ;
255263 }
@@ -283,7 +291,8 @@ protected function addParam($key, $value = null)
283291 if (is_null ($ value ))
284292 {
285293 $ this ->params [] = $ key ;
286- } else
294+ }
295+ else
287296 {
288297 $ this ->params [$ key ] = $ value ;
289298 }
@@ -364,12 +373,14 @@ public function __call($method, $args)
364373 if (isset ($ args [0 ]))
365374 {
366375 $ this ->addParam ($ param , $ args [0 ]);
367- } else
376+ }
377+ else
368378 {
369379 $ this ->addParam ($ param );
370380 }
371381 return $ this ;
372- } else
382+ }
383+ else
373384 {
374385 throw new PDFException ('Undefined method: ' . $ method );
375386 }
0 commit comments