PhpCsFixer\Fixer\Basic\BracesFixer::detectIndent PHP Method

detectIndent() private method

private detectIndent ( Tokens $tokens, integer $index ) : string
$tokens PhpCsFixer\Tokenizer\Tokens
$index integer
return string
    private function detectIndent(Tokens $tokens, $index)
    {
        while (true) {
            $whitespaceIndex = $tokens->getPrevTokenOfKind($index, array(array(T_WHITESPACE)));
            if (null === $whitespaceIndex) {
                return '';
            }
            $whitespaceToken = $tokens[$whitespaceIndex];
            if (false !== strpos($whitespaceToken->getContent(), "\n")) {
                break;
            }
            $prevToken = $tokens[$whitespaceIndex - 1];
            if ($prevToken->isGivenKind(array(T_OPEN_TAG, T_COMMENT)) && "\n" === substr($prevToken->getContent(), -1)) {
                break;
            }
            $index = $whitespaceIndex;
        }
        $explodedContent = explode("\n", $whitespaceToken->getContent());
        return end($explodedContent);
    }