Conditions | 5 |
Paths | 7 |
Total Lines | 26 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
34 | 3 | public function export(string $zipPathname, string $locale, array $domains = null): bool |
|
35 | { |
||
36 | 3 | $dir = dirname($zipPathname); |
|
37 | |||
38 | 3 | if (!is_dir($dir)) { |
|
39 | 1 | throw new InvalidArgumentException('Directory does not exist: ' . $dir); |
|
40 | } |
||
41 | |||
42 | 2 | $zip = new ZipArchive(); |
|
43 | 2 | $zip->open($zipPathname, ZipArchive::CREATE); |
|
44 | |||
45 | 2 | if (empty($domains)) { |
|
46 | 2 | $domains = $this->config->getOtherDomains(); |
|
47 | 2 | $domains[] = $this->config->getDefaultDomain(); |
|
48 | } |
||
49 | |||
50 | 2 | foreach ($domains as $domain) { |
|
51 | 2 | $po = $this->exporter->exportPoString($locale, $domain); |
|
52 | 2 | if ($po) { |
|
53 | 2 | $zip->addFromString($locale . '-' . $domain . '.po', $po); |
|
54 | } |
||
55 | } |
||
56 | |||
57 | 2 | $zip->close(); |
|
58 | |||
59 | 2 | return true; |
|
60 | } |
||
61 | } |