Completed
Push — master ( fca11f...8165c2 )
by Tobias
10:22
created

TwigVisitorFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\Extractor\Visitor\Twig;
13
14
/**
15
 * Create a TwigVisitor depending on what version of Twig is installed.
16
 *
17
 * @author Tobias Nyholm <[email protected]>
18
 */
19
final class TwigVisitorFactory
20
{
21
    /**
22
     * @return Twig1Visitor|Twig2Visitor
23
     */
24
    public static function create()
25
    {
26
        if (-1 === version_compare(\Twig_Environment::VERSION, '2.0')) {
27
            return new Twig1Visitor();
28
        }
29
30
        return new Twig2Visitor();
31
    }
32
}
33