Completed
Push — master ( 65f484...cb55bb )
by Asmir
07:37 queued 02:12
created

TwitalExtractor::visitPhpFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 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\Source;
10
11
/**
12
 *
13
 * @author Asmir Mustafic <[email protected]>
14
 *
15
 */
16
class TwitalExtractor implements FileVisitorInterface
17
{
18
    /**
19
     *
20
     * @var TwigFileExtractor
21
     */
22
    private $twigFileExtractor;
23
    /**
24
     *
25
     * @var \Goetas\Twital\TwitalLoader
26
     */
27
    private $twitalLoader;
28
    /**
29
     *
30
     * @var \Twig_Environment
31
     */
32
    private $twig;
33
34 1
    public function __construct(\Twig_Environment $twig, TwitalLoader $twitalLoader, TwigFileExtractor $twigFileExtractor)
35
    {
36 1
        $this->twig = $twig;
37 1
        $this->twitalLoader = $twitalLoader;
38 1
        $this->twigFileExtractor = $twigFileExtractor;
39 1
    }
40
41
    public function visitPhpFile(\SplFileInfo $file, MessageCatalogue $catalogue, array $ast)
42
    {
43
    }
44
45 View Code Duplication
    public function visitTwigFile(\SplFileInfo $file, MessageCatalogue $catalogue, \Twig_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...
46
    {
47
        if ($adapter = $this->twitalLoader->getSourceAdapter((string)$file)) {
48
49
            $source = $this->twitalLoader->getTwital()->compile($adapter, file_get_contents((string)$file));
50
51
            $ast = $this->twig->parse($this->twig->tokenize(new Source($source, (string)$file)));
52
        }
53
54
        $this->twigFileExtractor->visitTwigFile($file, $catalogue, $ast);
55
    }
56
57 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...
58
    {
59
        if ($adapter = $this->twitalLoader->getSourceAdapter((string)$file)) {
60
61
            $source = $this->twitalLoader->getTwital()->compile($adapter, file_get_contents((string)$file));
62
63
            $ast = $this->twig->parse($this->twig->tokenize(new Source($source, (string)$file)));
64
65
            $this->twigFileExtractor->visitTwigFile($file, $catalogue, $ast);
66
        }
67
    }
68
}
69