| Conditions | 6 | 
| Paths | 15 | 
| Total Lines | 28 | 
| Lines | 28 | 
| Ratio | 100 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 25 | View Code Duplication | public function merge(SourceInterface ...$sources): string | |
| 26 |     { | ||
| 27 | $sourceName = ''; | ||
| 28 | |||
| 29 |         try { | ||
| 30 | $tcpdi = clone $this->tcpdi; | ||
| 31 | |||
| 32 |             foreach ($sources as $source) { | ||
| 33 | $sourceName = $source->getName(); | ||
| 34 | $pageCount = $tcpdi->setSourceData($source->getContents()); | ||
| 35 | $pageNumbers = $source->getPages()->getPageNumbers() ?: range(1, $pageCount); | ||
| 36 | |||
| 37 |                 foreach ($pageNumbers as $pageNr) { | ||
| 38 | $template = $tcpdi->importPage($pageNr); | ||
| 39 | $size = $tcpdi->getTemplateSize($template); | ||
| 40 | $tcpdi->AddPage( | ||
| 41 | $size['w'] > $size['h'] ? 'L' : 'P', | ||
| 42 | [$size['w'], $size['h']] | ||
| 43 | ); | ||
| 44 | $tcpdi->useTemplate($template); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 |             return $tcpdi->Output('', 'S'); | ||
| 49 |         } catch (\Exception $e) { | ||
| 50 |             throw new Exception("'{$e->getMessage()}' in '$sourceName'", 0, $e); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | } | ||
| 54 |