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

VueJsFunctionScanner   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 13 1
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
}