JsCode   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromString() 0 7 1
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
            'dpgettext' => 'dpgettext',
26
            'dp__' => 'dpgettext',
27
            'npgettext' => 'npgettext',
28
            'np__' => 'npgettext',
29
            'dnpgettext' => 'dnpgettext',
30
            'dnp__' => 'dnpgettext',
31
            'noop' => 'noop',
32
            'noop__' => 'noop',
33
        ],
34
    ];
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public static function fromString($string, Translations $translations, array $options = [])
40
    {
41
        $options += static::$options;
42
43
        $functions = new JsFunctionsScanner($string);
44
        $functions->saveGettextFunctions($translations, $options);
45
    }
46
}
47