CatalogueWriter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 24
ccs 0
cts 15
cp 0
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A writeCatalogues() 0 10 2
A __construct() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\Bundle\Catalogue;
13
14
use Symfony\Component\Translation\MessageCatalogue;
15
use Symfony\Component\Translation\Writer\TranslationWriterInterface;
16
use Translation\Bundle\Model\Configuration;
17
18
/**
19
 * Write catalogues back to disk.
20
 *
21
 * This should be considered as a "WriteToCache" service.
22
 *
23
 * @author Tobias Nyholm <[email protected]>
24
 */
25
final class CatalogueWriter
26
{
27
    private $writer;
28
    private $defaultLocale;
29
30
    public function __construct(TranslationWriterInterface $writer, string $defaultLocale)
31
    {
32
        $this->writer = $writer;
33
        $this->defaultLocale = $defaultLocale;
34
    }
35
36
    /**
37
     * @param MessageCatalogue[] $catalogues
38
     */
39
    public function writeCatalogues(Configuration $config, array $catalogues): void
40
    {
41
        foreach ($catalogues as $catalogue) {
42
            $this->writer->write(
43
                $catalogue,
44
                $config->getOutputFormat(),
45
                [
46
                    'path' => $config->getOutputDir(),
47
                    'default_locale' => $this->defaultLocale,
48
                    'xliff_version' => $config->getXliffVersion(),
49
                ]
50
            );
51
        }
52
    }
53
}
54