Total Complexity | 4 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Converter |
||
10 | { |
||
11 | private readonly string $epubDirectory; |
||
12 | |||
13 | /** |
||
14 | * Converter constructor. |
||
15 | * |
||
16 | * @param string $epubDirectory The directory containing the extracted EPUB contents. |
||
17 | * @param array<string, ConverterInterface> $adapters A map of format to converter adapters. |
||
18 | */ |
||
19 | public function __construct(string $epubDirectory, private array $adapters) |
||
20 | { |
||
21 | if (! is_dir($epubDirectory)) { |
||
22 | throw new Exception("EPUB directory does not exist: {$epubDirectory}"); |
||
23 | } |
||
24 | |||
25 | $this->epubDirectory = $epubDirectory; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Converts the EPUB to a specified format. |
||
30 | * |
||
31 | * @param string $format The format to convert to (e.g., 'pdf', 'mobi'). |
||
32 | * @param string $outputPath The path where the converted file should be saved. |
||
33 | * |
||
34 | * @throws Exception If the conversion fails or the format is not supported. |
||
35 | */ |
||
36 | public function convert(string $format, string $outputPath): void |
||
44 | } |
||
45 | } |
||
46 |