ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
TextBase.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Data\Text;
22
23abstract class TextBase implements Text
24{
25 public function __construct(
26 protected Shape $shape,
27 protected string $raw
28 ) {
29 if (!$shape->isRawStringCompliant($raw)) {
30 throw new \InvalidArgumentException("The provided string is not compliant with the supported structure!");
31 }
32 }
33
34 public function getShape(): Shape
35 {
36 return $this->shape;
37 }
38
39 public function getMarkup(): Markup
40 {
41 return $this->shape->getMarkup();
42 }
43
47 public function getSupportedStructure(): array
48 {
49 return $this->shape->getSupportedStructure();
50 }
51
52 public function toHTML(): HTML
53 {
54 return $this->shape->toHTML($this);
55 }
56
57 public function toPlainText(): PlainText
58 {
59 return $this->shape->toPlainText($this);
60 }
61
62 public function getRawRepresentation(): string
63 {
64 return $this->raw;
65 }
66}
This class currently is a stub only.
Definition: HTML.php:28
This class currently is a stub only.
Definition: PlainText.php:28
__construct(protected Shape $shape, protected string $raw)
Definition: TextBase.php:25
Methods in this interface should mostly be called by the according methods on Text instances,...
Definition: Shape.php:35
isRawStringCompliant(string $text)