Completed
Pull Request — master (#178)
by Mārtiņš
01:27
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
4
namespace Gettext\Utils;
5
6
7
class VueJsFunctionScanner extends JsFunctionsScanner
8
{
9
    /**
10
     * Number of lines that the the script of the template starts
11
     * @var int
12
     */
13
    public $lineOffset = 0;
14
15
    /**
16
     * @inheritdoc
17
     */
18
    public function getFunctions(array $constants = [])
19
    {
20
        $functions = parent::getFunctions($constants);
21
22
        // Add line offset to the functions because vue templates contain template at the top and the script is below.
23
        // When we parse, we parse only the script part so we need to add the line number
24
        $functions = array_map(function ($v) {
25
            $v[1] += $this->lineOffset - 1;
26
            return $v;
27
        }, $functions);
28
29
        return $functions;
30
    }
31
}