These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\SymfonyStorage\Dumper; |
||
13 | |||
14 | use Nyholm\NSA; |
||
15 | use Symfony\Component\Translation\Dumper\XliffFileDumper; |
||
16 | use Symfony\Component\Translation\MessageCatalogue; |
||
17 | use Symfony\Component\Translation\Exception\InvalidArgumentException; |
||
18 | use Translation\SymfonyStorage\Dumper\Port\SymfonyPort; |
||
19 | |||
20 | /** |
||
21 | * XliffFileDumper generates xliff files from a message catalogue. |
||
22 | * |
||
23 | * This class provides support for both SF2.7 and SF3.0+ |
||
24 | * |
||
25 | * @author Tobias Nyholm <[email protected]> |
||
26 | * @author Michel Salib <[email protected]> |
||
27 | */ |
||
28 | final class XliffDumper extends XliffFileDumper |
||
29 | { |
||
30 | /** |
||
31 | * @var SymfonyPort|null |
||
32 | */ |
||
33 | private $sfPort; |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 3 | public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) |
|
39 | { |
||
40 | 3 | $xliffVersion = '1.2'; |
|
41 | 3 | if (array_key_exists('xliff_version', $options)) { |
|
42 | 3 | $xliffVersion = $options['xliff_version']; |
|
43 | 3 | } |
|
44 | |||
45 | 3 | if (array_key_exists('default_locale', $options)) { |
|
46 | $defaultLocale = $options['default_locale']; |
||
47 | } else { |
||
48 | 3 | $defaultLocale = \Locale::getDefault(); |
|
49 | } |
||
50 | |||
51 | 3 | if ('1.2' === $xliffVersion) { |
|
52 | 1 | if (method_exists($this, 'dumpXliff1')) { |
|
53 | 1 | return NSA::invokeMethod($this, 'dumpXliff1', $defaultLocale, $messages, $domain, $options); |
|
54 | } else { |
||
55 | // Symfony 2.7 |
||
56 | return $this->format($messages, $domain); |
||
0 ignored issues
–
show
|
|||
57 | } |
||
58 | } |
||
59 | |||
60 | 2 | if ('2.0' === $xliffVersion) { |
|
61 | 2 | if (null === $this->sfPort) { |
|
62 | 2 | $this->sfPort = new SymfonyPort(); |
|
63 | 2 | } |
|
64 | |||
65 | 2 | return $this->sfPort->dumpXliff2($defaultLocale, $messages, $domain, $options); |
|
66 | } |
||
67 | |||
68 | throw new InvalidArgumentException( |
||
69 | sprintf('No support implemented for dumping XLIFF version "%s".', $xliffVersion) |
||
70 | 1 | ); |
|
71 | } |
||
72 | } |
||
73 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.