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