Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Comment.php

function Comment::setRawText

Sets the comment raw text

Parameters

string $rawText Comment raw text:

Return value

$this

File

vendor/mck89/peast/lib/Peast/Syntax/Node/Comment.php, line 152

Class

Comment
A node that represents a comment.

Namespace

Peast\Syntax\Node

Code

public function setRawText($rawText) {
    $start = substr($rawText, 0, 2);
    if ($start === "//") {
        $kind = self::KIND_INLINE;
        $text = substr($rawText, 2);
    }
    elseif ($start === "/*" && substr($rawText, -2) === "*/") {
        $kind = self::KIND_MULTILINE;
        $text = substr($rawText, 2, -2);
    }
    elseif ($start === "#!") {
        $kind = self::KIND_HASHBANG;
        $text = substr($rawText, 2);
    }
    elseif ($start === "<!" && substr($rawText, 2, 2) === "--") {
        $kind = self::KIND_HTML_OPEN;
        $text = substr($rawText, 4);
    }
    elseif ($start === "--" && substr($rawText, 2, 1) === ">") {
        $kind = self::KIND_HTML_CLOSE;
        $text = substr($rawText, 3);
    }
    else {
        throw new \Exception("Invalid comment");
    }
    return $this->setKind($kind)
        ->setText($text);
}
RSS feed
Powered by Drupal