Completed
Pull Request — master (#119)
by T
03:06
created

Factory::factory()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 23
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 21
nc 1
nop 1
dl 0
loc 32
ccs 23
cts 23
cp 1
crap 1
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer;
7
8
use PHPSA\Analyzer;
9
use Webiny\Component\EventManager\EventManager;
10
use PHPSA\Analyzer\Pass as AnalyzerPass;
11
12
class Factory
13
{
14
    /**
15
     * @param EventManager $eventManager
16
     * @return Analyzer
17
     */
18 1
    public static function factory(EventManager $eventManager)
0 ignored issues
show
Best Practice introduced by
Using PHP4-style constructors that are named like the class is not recommend; better use the more explicit __construct method.
Loading history...
19
    {
20 1
        $analyzer = new Analyzer($eventManager);
21 1
        $analyzer->registerExpressionPasses(
22
            [
23
                // Another
24 1
                new AnalyzerPass\Expression\ArrayShortDefinition(),
25 1
                new AnalyzerPass\Expression\ErrorSuppression(),
26 1
                new AnalyzerPass\Expression\VariableVariableUsage(),
27
                // Function call
28 1
                new AnalyzerPass\Expression\FunctionCall\AliasCheck(),
29 1
                new AnalyzerPass\Expression\FunctionCall\DebugCode(),
30 1
                new AnalyzerPass\Expression\FunctionCall\RandomApiMigration(),
31 1
                new AnalyzerPass\Expression\FunctionCall\UseCast(),
32 1
                new AnalyzerPass\Expression\FunctionCall\DeprecatedIniOptions(),
33 1
                new AnalyzerPass\Expression\FunctionCall\RegularExpressions(),
34 1
                new AnalyzerPass\Expression\FunctionCall\ArgumentUnpacking(),
35 1
                new AnalyzerPass\Expression\FunctionCall\DeprecatedFunctions(),
36
            ]
37 1
        );
38 1
        $analyzer->registerStatementPasses(
39
            [
40 1
                new AnalyzerPass\Statement\DoNotUseGoto(),
41 1
                new AnalyzerPass\Statement\MissingBreakStatement(),
42 1
                new AnalyzerPass\Statement\MethodCannotReturn(),
43 1
                new AnalyzerPass\Statement\UnexpectedUseOfThis(),
44
            ]
45 1
        );
46 1
        $analyzer->bind();
47
48 1
        return $analyzer;
49
    }
50
}
51