Factory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 19
Ratio 100 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 19
loc 19
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace PhpSchool\PSX;
4
5
use PhpParser\ParserFactory;
6
use Colors\Color;
7
8
/**
9
 * Class Factory
10
 * @package PhpSchool\PSX
11
 * @author Aydin Hassan <[email protected]>
12
 */
13
class Factory
14
{
15
    /**
16
     * @return SyntaxHighlighter
17
     */
18 View Code Duplication
    public function __invoke()
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...
19
    {
20
        $lexer = new Lexer([
21
            'usedAttributes' => [
22
                'comments', 'startLine', 'endLine', 'startFilePos', 'endFilePos', 'startTokenPos', 'endTokenPos'
23
            ]
24
        ]);
25
        
26
        $parserFactory = new ParserFactory;
27
        $color = new Color;
28
        $color->setForceStyle(true);
29
        return new SyntaxHighlighter(
30
            $parserFactory->create(ParserFactory::PREFER_PHP7, $lexer),
31
            new SyntaxHighlightPrinter(
32
                new SyntaxHighlighterConfig,
33
                new ColorsAdapter($color)
34
            )
35
        );
36
    }
37
}
38