Completed
Pull Request — master (#219)
by David
01:14
created

JsCode::fromStringMultiple()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
cc 1
nc 1
nop 3
rs 10
1
<?php
2
3
namespace Gettext\Extractors;
4
5
use Gettext\Translations;
6
use Gettext\Utils\JsFunctionsScanner;
7
8
/**
9
 * Class to get gettext strings from javascript files.
10
 */
11
class JsCode extends Extractor implements ExtractorInterface
12
{
13
    public static $options = [
14
        'constants' => [],
15
16
        'functions' => [
17
            'gettext' => 'gettext',
18
            '__' => 'gettext',
19
            'ngettext' => 'ngettext',
20
            'n__' => 'ngettext',
21
            'pgettext' => 'pgettext',
22
            'p__' => 'pgettext',
23
            'dgettext' => 'dgettext',
24
            'd__' => 'dgettext',
25
            'dngettext' => 'dngettext',
26
            'dn__' => 'dngettext',
27
            'dpgettext' => 'dpgettext',
28
            'dp__' => 'dpgettext',
29
            'npgettext' => 'npgettext',
30
            'np__' => 'npgettext',
31
            'dnpgettext' => 'dnpgettext',
32
            'dnp__' => 'dnpgettext',
33
            'noop' => 'noop',
34
            'noop__' => 'noop',
35
        ],
36
    ];
37
38
    /**
39
     * {@inheritdoc}
40
     * @throws \Exception
41
     */
42
    public static function fromString($string, Translations $translations, array $options = [])
43
    {
44
        $options += static::$options;
45
46
        $functions = new JsFunctionsScanner($string);
47
        $functions->saveGettextFunctions($translations, $options);
48
    }
49
}
50