| Conditions | 6 | 
| Paths | 15 | 
| Total Lines | 29 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 23 | public function merge(SourceInterface ...$sources): string | ||
| 24 |     { | ||
| 25 | /** @var string Name of source being processed */ | ||
| 26 | $name = ''; | ||
| 27 | |||
| 28 |         try { | ||
| 29 | $tcpdi = clone $this->tcpdi; | ||
| 30 | |||
| 31 |             foreach ($sources as $source) { | ||
| 32 | $name = $source->getName(); | ||
| 33 | $pageCount = $tcpdi->setSourceData($source->getContents()); | ||
| 34 |                 $pages = $source->getPages()->isEmpty() ? $source->getPages() : new Pages("1-$pageCount"); | ||
| 35 | |||
| 36 |                 foreach ($pages as $page) { | ||
| 37 | $template = $tcpdi->importPage($page); | ||
| 38 | $size = $tcpdi->getTemplateSize($template); | ||
| 39 | $tcpdi->AddPage( | ||
| 40 | $size['w'] > $size['h'] ? 'L' : 'P', | ||
| 41 | [$size['w'], $size['h']] | ||
| 42 | ); | ||
| 43 | $tcpdi->useTemplate($template); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 |             return $tcpdi->Output('', 'S'); | ||
| 48 |         } catch (\Exception $e) { | ||
| 49 |             throw new Exception("'{$e->getMessage()}' in '{$name}'", 0, $e); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | } | ||
| 53 |