Completed
Pull Request — master (#178)
by Mārtiņš
01:25
created

VueJsFunctionScanner::getFunctions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Gettext\Utils;
4
5
class VueJsFunctionScanner extends JsFunctionsScanner
6
{
7
    /**
8
     * Number of lines that the the script of the template starts
9
     * @var int
10
     */
11
    public $lineOffset = 0;
12
13
    /**
14
     * @inheritdoc
15
     */
16
    public function getFunctions(array $constants = [])
17
    {
18
        $functions = parent::getFunctions($constants);
19
20
        // Add line offset to the functions because vue templates contain template at the top and the script is below.
21
        // When we parse, we parse only the script part so we need to add the line number
22
        $functions = array_map(function ($v) {
23
            $v[1] += $this->lineOffset - 1;
24
            return $v;
25
        }, $functions);
26
27
        return $functions;
28
    }
29
}
30