IndentationIssue   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 48
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A amountOfIndentChars() 0 3 1
A __construct() 0 11 2
A indentationCharacter() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Pluswerk\TypoScriptAutoFixer\Issue;
5
6
use Pluswerk\TypoScriptAutoFixer\Exception\InvalidIndentationCharacterException;
7
8
final class IndentationIssue extends AbstractIssue
9
{
10
    private const ALLOWED_INDENTATION_CHARS = [' ', "\t"];
11
12
    /**
13
     * @var int
14
     */
15
    private $amountOfIndentChars;
16
17
    /**
18
     * @var string
19
     */
20
    private $indentationCharacter;
21
22
    /**
23
     * IndentationIssue constructor.
24
     *
25
     * @param int    $line
26
     * @param int    $amountOfIndentChars
27
     * @param string $indentationCharacter
28
     */
29
    public function __construct(int $line, int $amountOfIndentChars, string $indentationCharacter = ' ')
30
    {
31
        parent::__construct($line);
32
33
        $this->amountOfIndentChars = $amountOfIndentChars;
34
35
        if (!in_array($indentationCharacter, self::ALLOWED_INDENTATION_CHARS)) {
36
            throw new InvalidIndentationCharacterException('Given indentation character ' . $indentationCharacter . ' is invalid!');
37
        }
38
39
        $this->indentationCharacter = $indentationCharacter;
40
    }
41
42
    /**
43
     * @return int
44
     */
45
    public function amountOfIndentChars(): int
46
    {
47
        return $this->amountOfIndentChars;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function indentationCharacter(): string
54
    {
55
        return $this->indentationCharacter;
56
    }
57
}
58