Factory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 76 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 1
c 2
b 1
f 0
lcom 0
cbo 7
dl 19
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 19 19 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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