1 | <?php |
||
10 | class Merger |
||
11 | { |
||
12 | /** |
||
13 | * Array of files to be merged. |
||
14 | * |
||
15 | * Values for each files are filename, Pages object and a boolean value |
||
16 | * indicating if the file should be deleted after merging is complete. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | private $files = array(); |
||
21 | |||
22 | /** |
||
23 | * @var \FPDI Fpdi object |
||
24 | */ |
||
25 | private $fpdi; |
||
26 | |||
27 | /** |
||
28 | * @var string Directory path used for temporary files |
||
29 | */ |
||
30 | private $tempDir; |
||
31 | |||
32 | /** |
||
33 | * Constructor |
||
34 | * |
||
35 | * @param \FPDI $fpdi |
||
36 | */ |
||
37 | public function __construct(\FPDI $fpdi = null) |
||
41 | |||
42 | /** |
||
43 | * Add raw PDF from string |
||
44 | * |
||
45 | * Note that your PDFs are merged in the order that you add them |
||
46 | * |
||
47 | * @param string $pdf |
||
48 | * @param Pages $pages |
||
49 | * @return void |
||
50 | * @throws Exception if unable to create temporary file |
||
51 | */ |
||
52 | public function addRaw($pdf, Pages $pages = null) |
||
64 | |||
65 | /** |
||
66 | * Add PDF from filesystem path |
||
67 | * |
||
68 | * Note that your PDFs are merged in the order that you add them |
||
69 | * |
||
70 | * @param string $fname Name of file to add |
||
71 | * @param Pages $pages Pages to add from file |
||
72 | * @param bool $cleanup Flag if file should be deleted after merging |
||
73 | * @return void |
||
74 | * @throws Exception If $fname is not a valid file |
||
75 | */ |
||
76 | public function addFromFile($fname, Pages $pages = null, $cleanup = false) |
||
91 | |||
92 | /** |
||
93 | * Add files using iterator |
||
94 | * |
||
95 | * @param array|\Traversable $iterator |
||
96 | * @return void |
||
97 | * @throws Exception If $iterator is not valid |
||
98 | */ |
||
99 | public function addIterator($iterator) |
||
109 | |||
110 | /** |
||
111 | * Add files using symfony finder |
||
112 | * |
||
113 | * @param Finder $finder |
||
114 | * @return void |
||
115 | */ |
||
116 | public function addFinder(Finder $finder) |
||
122 | |||
123 | /** |
||
124 | * Merges your provided PDFs and get raw string |
||
125 | * |
||
126 | * @return string |
||
127 | * @throws Exception If no PDFs were added |
||
128 | * @throws Exception If a specified page does not exist |
||
129 | */ |
||
130 | public function merge() |
||
177 | |||
178 | /** |
||
179 | * Create temporary file and return name |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | public function getTempFname() |
||
187 | |||
188 | /** |
||
189 | * Get directory path for temporary files |
||
190 | * |
||
191 | * Set path using setTempDir(), defaults to sys_get_temp_dir(). |
||
192 | * |
||
193 | * @return string |
||
194 | */ |
||
195 | public function getTempDir() |
||
199 | |||
200 | /** |
||
201 | * Set directory path for temporary files |
||
202 | * |
||
203 | * @param string $dirname |
||
204 | * @return void |
||
205 | */ |
||
206 | public function setTempDir($dirname) |
||
210 | } |
||
211 |
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.