Skip to content

Commit 9d5c3ce

Browse files
committed
Cleanup
1 parent d70c1e9 commit 9d5c3ce

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

SlevomatCodingStandard/Sniffs/ControlStructures/RequireMultiLineTernaryOperatorSniff.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PHP_CodeSniffer\Files\File;
66
use PHP_CodeSniffer\Sniffs\Sniff;
77
use SlevomatCodingStandard\Helpers\FixerHelper;
8+
use SlevomatCodingStandard\Helpers\IndentationHelper;
89
use SlevomatCodingStandard\Helpers\SniffSettingsHelper;
910
use SlevomatCodingStandard\Helpers\TernaryOperatorHelper;
1011
use SlevomatCodingStandard\Helpers\TokenHelper;
@@ -24,9 +25,6 @@ class RequireMultiLineTernaryOperatorSniff implements Sniff
2425

2526
public const CODE_MULTI_LINE_TERNARY_OPERATOR_NOT_USED = 'MultiLineTernaryOperatorNotUsed';
2627

27-
private const TAB_INDENT = "\t";
28-
private const SPACES_INDENT = ' ';
29-
3028
/** @var int */
3129
public $lineLengthLimit = 0;
3230

@@ -167,11 +165,14 @@ private function getIndentation(File $phpcsFile, int $endOfLinePointer): string
167165
$actualIndentation = TokenHelper::getContent($phpcsFile, $endOfLinePointer + 1, $pointerAfterWhitespace - 1);
168166

169167
if (strlen($actualIndentation) !== 0) {
170-
return $actualIndentation . (substr($actualIndentation, -1) === self::TAB_INDENT ? self::TAB_INDENT : self::SPACES_INDENT);
168+
return $actualIndentation . (substr(
169+
$actualIndentation,
170+
-1
171+
) === IndentationHelper::TAB_INDENT ? IndentationHelper::TAB_INDENT : IndentationHelper::SPACES_INDENT);
171172
}
172173

173-
$tabPointer = TokenHelper::findPreviousContent($phpcsFile, T_WHITESPACE, self::TAB_INDENT, $endOfLinePointer - 1);
174-
return $tabPointer !== null ? self::TAB_INDENT : self::SPACES_INDENT;
174+
$tabPointer = TokenHelper::findPreviousContent($phpcsFile, T_WHITESPACE, IndentationHelper::TAB_INDENT, $endOfLinePointer - 1);
175+
return $tabPointer !== null ? IndentationHelper::TAB_INDENT : IndentationHelper::SPACES_INDENT;
175176
}
176177

177178
}

0 commit comments

Comments
 (0)