TwitalExtractor::visitPhpFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
namespace Goetas\TwitalBundle\Translation\Jms;
4
5
use Goetas\Twital\TwitalLoader;
6
use JMS\TranslationBundle\Model\MessageCatalogue;
7
use JMS\TranslationBundle\Translation\Extractor\File\TwigFileExtractor;
8
use JMS\TranslationBundle\Translation\Extractor\FileVisitorInterface;
9
use Twig\Environment;
10
use Twig\Node\Node;
11
use Twig\Source;
12
13
/**
14
 *
15
 * @author Asmir Mustafic <[email protected]>
16
 *
17
 */
18
class TwitalExtractor implements FileVisitorInterface
19
{
20
    /**
21
     *
22
     * @var TwigFileExtractor
23
     */
24
    private $twigFileExtractor;
25
    /**
26
     *
27
     * @var TwitalLoader
28
     */
29
    private $twitalLoader;
30
    /**
31
     *
32
     * @var Environment
33
     */
34 1
    private $twig;
35
36 1
    public function __construct(Environment $twig, TwitalLoader $twitalLoader, TwigFileExtractor $twigFileExtractor)
37 1
    {
38 1
        $this->twig = $twig;
39 1
        $this->twitalLoader = $twitalLoader;
40
        $this->twigFileExtractor = $twigFileExtractor;
41
    }
42
43
    public function visitPhpFile(\SplFileInfo $file, MessageCatalogue $catalogue, array $ast)
44
    {
45
    }
46
47 View Code Duplication
    public function visitTwigFile(\SplFileInfo $file, MessageCatalogue $catalogue, Node $ast)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        if ($adapter = $this->twitalLoader->getSourceAdapter((string)$file)) {
50
51
            $source = $this->twitalLoader->getTwital()->compile($adapter, file_get_contents((string)$file));
52
53
            $ast = $this->twig->parse($this->twig->tokenize(new Source($source, (string)$file)));
54
        }
55
56
        $this->twigFileExtractor->visitTwigFile($file, $catalogue, $ast);
57
    }
58
59 View Code Duplication
    function visitFile(\SplFileInfo $file, MessageCatalogue $catalogue)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
    {
61
        if ($adapter = $this->twitalLoader->getSourceAdapter((string)$file)) {
62
63
            $source = $this->twitalLoader->getTwital()->compile($adapter, file_get_contents((string)$file));
64
65
            $ast = $this->twig->parse($this->twig->tokenize(new Source($source, (string)$file)));
66
67
            $this->twigFileExtractor->visitTwigFile($file, $catalogue, $ast);
68
        }
69
    }
70
}
71