private function getValue(Iterator $tokenIterator): string
    {
        $message  = '';
        $docToken = '';

        for (; $tokenIterator->valid(); $tokenIterator->next()) {
            $t = $tokenIterator->current();

            if (! isset($t[1])) {
                break;
            }

            switch ($t[0]) {
                case \T_START_HEREDOC:
                    $docToken = $t[1];

                    break;
                case \T_ENCAPSED_AND_WHITESPACE:
                case \T_CONSTANT_ENCAPSED_STRING:
                    $message .= $t[1];

                    break;
                case \T_END_HEREDOC:
                    return ScalarString::parseDocString($docToken, $message);

                default:
                    break 2;
            }
        }

        if ($message) {
            $message = ScalarString::parse($message);
        }

        return $message;
    }