diff --git a/src/Document.php b/src/Document.php index 0fdf23b..f75a6be 100644 --- a/src/Document.php +++ b/src/Document.php @@ -60,6 +60,17 @@ class Document break; + // Quote + case Parser\Quote::match($line): + + $this->_entities[] = new Entity\Quote( + Parser\Quote::getText( + $line + ) + ); + + break; + // Plain default: diff --git a/src/Entity/Quote.php b/src/Entity/Quote.php new file mode 100644 index 0000000..4adef6a --- /dev/null +++ b/src/Entity/Quote.php @@ -0,0 +1,44 @@ +'; + + private ?string $_text; + + public function __construct( + ?string $text = null + ) { + $this->setText( + $text + ); + } + + public function setText( + ?string $text + ): void + { + if ($text) + { + $text = trim( + $text + ); + } + + $this->_text = $text; + } + + public function Text(): ?string + { + return $this->_text; + } + + public function toString(): string + { + return self::TAG . ' ' . $this->_text; + } +} \ No newline at end of file diff --git a/src/Parser/Quote.php b/src/Parser/Quote.php new file mode 100644 index 0000000..507be4d --- /dev/null +++ b/src/Parser/Quote.php @@ -0,0 +1,44 @@ +\s*(?.*)$/m', + $line, + $matches + ); + } + + public static function getText( + string $line + ): ?string + { + $matches = []; + + if (self::match($line, $matches)) + { + if (isset($matches['text'])) + { + $text = trim( + $matches['text'] + ); + + if ($text) + { + return $text; + } + } + } + + return null; + } +} \ No newline at end of file