Completed
Push — php7 ( e63b6c...54c9f9 )
by Akihito
01:32
created

ParserFactory::newInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 2
cts 3
cp 0.6667
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
crap 2.1481
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the Ray.Aop package
6
 *
7
 * @license http://opensource.org/licenses/MIT MIT
8
 */
9
namespace Ray\Aop;
10
11
use PhpParser\Lexer;
12
use PhpParser\Parser;
13
use PhpParser\ParserFactory as PhpParserFactory;
14
15
class ParserFactory
16
{
17 27
    public function newInstance()
18
    {
19 27
        if (class_exists('PhpParser\ParserFactory')) {
20
            return (new PhpParserFactory)->create(PhpParserFactory::PREFER_PHP7);
21
        }
22
23
        return new Parser(new Lexer());  // @codeCoverageIgnore
24
    }
25
}
26