FixerFactory   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 14
c 1
b 0
f 0
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFixerByIssue() 0 16 5
1
<?php
2
declare(strict_types=1);
3
4
namespace Pluswerk\TypoScriptAutoFixer\Fixer;
5
6
use Pluswerk\TypoScriptAutoFixer\Exception\FixerNotFoundException;
7
use Pluswerk\TypoScriptAutoFixer\Fixer\EmptySection\EmptySectionFixer;
8
use Pluswerk\TypoScriptAutoFixer\Fixer\NestingConsistency\NestingConsistencyFixer;
9
use Pluswerk\TypoScriptAutoFixer\Fixer\Indentation\IndentationFixer;
10
use Pluswerk\TypoScriptAutoFixer\Fixer\OperatorWhitespace\OperatorWhitespaceFixer;
11
use Pluswerk\TypoScriptAutoFixer\Issue\AbstractIssue;
12
use Pluswerk\TypoScriptAutoFixer\Issue\EmptySectionIssue;
13
use Pluswerk\TypoScriptAutoFixer\Issue\IndentationIssue;
14
use Pluswerk\TypoScriptAutoFixer\Issue\NestingConsistencyIssue;
15
use Pluswerk\TypoScriptAutoFixer\Issue\OperatorWhitespaceIssue;
16
17
class FixerFactory
18
{
19
    /**
20
     * @param AbstractIssue $issue
21
     *
22
     * @return FixerInterface|null
23
     */
24
    public function getFixerByIssue(AbstractIssue $issue): ?FixerInterface
25
    {
26
        switch (get_class($issue)) {
27
            case OperatorWhitespaceIssue::class:
28
                return new OperatorWhitespaceFixer();
29
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
30
            case IndentationIssue::class:
31
                return new IndentationFixer();
32
                break;
33
            case EmptySectionIssue::class:
34
                return new EmptySectionFixer();
35
                break;
36
            case NestingConsistencyIssue::class:
37
                return new NestingConsistencyFixer();
38
        }
39
        throw new FixerNotFoundException('Fixer for issue ' . get_class($issue) . ' not found');
40
    }
41
}
42