IndentationFixer::fixIssue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Pluswerk\TypoScriptAutoFixer\Fixer\Indentation;
5
6
use Pluswerk\TypoScriptAutoFixer\File;
7
use Pluswerk\TypoScriptAutoFixer\FileBuilder;
8
use Pluswerk\TypoScriptAutoFixer\Fixer\AbstractFixer;
9
use Pluswerk\TypoScriptAutoFixer\Issue\AbstractIssue;
10
use Pluswerk\TypoScriptAutoFixer\Issue\IndentationIssue;
11
12
final class IndentationFixer extends AbstractFixer
13
{
14
    /**
15
     * @var LineFixer
16
     */
17
    private $lineFixer;
18
19
    /**
20
     * IndentationFixer constructor.
21
     *
22
     * @param FileBuilder|null $fileBuilder
23
     * @param LineFixer|null   $lineFixer
24
     */
25
    public function __construct(FileBuilder $fileBuilder = null, LineFixer $lineFixer = null)
26
    {
27
        parent::__construct($fileBuilder);
28
        $this->lineFixer = $lineFixer ?? new LineFixer();
29
    }
30
31
    /**
32
     * @param File          $file
33
     * @param AbstractIssue|IndentationIssue $issue
34
     *
35
     * @return File
36
     */
37
    public function fixIssue(File $file, AbstractIssue $issue): File
38
    {
39
        $line = $file->readLine($issue->line());
40
        $line = $this->lineFixer->fixIndentation($line, $issue->amountOfIndentChars(), $issue->indentationCharacter());
0 ignored issues
show
Bug introduced by
The method amountOfIndentChars() does not exist on Pluswerk\TypoScriptAutoFixer\Issue\AbstractIssue. It seems like you code against a sub-type of Pluswerk\TypoScriptAutoFixer\Issue\AbstractIssue such as Pluswerk\TypoScriptAutoF...\Issue\IndentationIssue. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        $line = $this->lineFixer->fixIndentation($line, $issue->/** @scrutinizer ignore-call */ amountOfIndentChars(), $issue->indentationCharacter());
Loading history...
Bug introduced by
The method indentationCharacter() does not exist on Pluswerk\TypoScriptAutoFixer\Issue\AbstractIssue. It seems like you code against a sub-type of Pluswerk\TypoScriptAutoFixer\Issue\AbstractIssue such as Pluswerk\TypoScriptAutoF...\Issue\IndentationIssue. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        $line = $this->lineFixer->fixIndentation($line, $issue->amountOfIndentChars(), $issue->/** @scrutinizer ignore-call */ indentationCharacter());
Loading history...
41
        $file->replaceLine($line, $issue->line());
42
        return $this->fileBuilder->buildFile($file->getPathname());
43
    }
44
}
45