| @@ 21-63 (lines=43) @@ | ||
| 18 | * @property Wrapper $html Get html `pre` wrapped code |
|
| 19 | * @author Piotr Maselkowski <pmaselkowski at gmail.com> |
|
| 20 | */ |
|
| 21 | class InlineWrapper |
|
| 22 | { |
|
| 23 | ||
| 24 | private $text = ''; |
|
| 25 | private $isMd = false; |
|
| 26 | private $isHtml = false; |
|
| 27 | ||
| 28 | public function __construct($text) |
|
| 29 | { |
|
| 30 | $this->text = $text; |
|
| 31 | } |
|
| 32 | ||
| 33 | public function __get($name) |
|
| 34 | { |
|
| 35 | return $this->$name(); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function md() |
|
| 39 | { |
|
| 40 | $this->isMd = true; |
|
| 41 | return $this; |
|
| 42 | } |
|
| 43 | ||
| 44 | public function html() |
|
| 45 | { |
|
| 46 | $this->isHtml = true; |
|
| 47 | return $this; |
|
| 48 | } |
|
| 49 | ||
| 50 | public function __toString() |
|
| 51 | { |
|
| 52 | if ($this->isMd) |
|
| 53 | { |
|
| 54 | return "`$this->text`"; |
|
| 55 | } |
|
| 56 | if ($this->isHtml) |
|
| 57 | { |
|
| 58 | return "<code>$this->text</code>"; |
|
| 59 | } |
|
| 60 | return $this->text; |
|
| 61 | } |
|
| 62 | ||
| 63 | } |
|
| 64 | ||
| @@ 21-71 (lines=51) @@ | ||
| 18 | * @property Wrapper $html Get html `pre` wrapped code |
|
| 19 | * @author Piotr Maselkowski <pmaselkowski at gmail.com> |
|
| 20 | */ |
|
| 21 | class Wrapper |
|
| 22 | { |
|
| 23 | ||
| 24 | private $text = ''; |
|
| 25 | private $isMd = false; |
|
| 26 | private $isHtml = false; |
|
| 27 | ||
| 28 | public function __construct($text) |
|
| 29 | { |
|
| 30 | $this->text = $text; |
|
| 31 | } |
|
| 32 | ||
| 33 | public function __get($name) |
|
| 34 | { |
|
| 35 | return $this->$name(); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function md() |
|
| 39 | { |
|
| 40 | $this->isMd = true; |
|
| 41 | return $this; |
|
| 42 | } |
|
| 43 | ||
| 44 | public function html() |
|
| 45 | { |
|
| 46 | $this->isHtml = true; |
|
| 47 | return $this; |
|
| 48 | } |
|
| 49 | ||
| 50 | public function __toString() |
|
| 51 | { |
|
| 52 | if ($this->isMd) |
|
| 53 | { |
|
| 54 | return <<<TEXT |
|
| 55 | ```php |
|
| 56 | $this->text |
|
| 57 | ``` |
|
| 58 | TEXT; |
|
| 59 | } |
|
| 60 | if ($this->isHtml) |
|
| 61 | { |
|
| 62 | return <<<TEXT |
|
| 63 | <pre> |
|
| 64 | $this->text |
|
| 65 | </pre> |
|
| 66 | TEXT; |
|
| 67 | } |
|
| 68 | return $this->text; |
|
| 69 | } |
|
| 70 | ||
| 71 | } |
|
| 72 | ||