Debian Codegraph @

vendor/ipl/html/src/FormDecoration/Transformation.php

raw
1 <?php
2
3 namespace ipl\Html\FormDecoration;
4
5 use ipl\Html\Contract\DecorationResult;
6 use ipl\Html\Contract\MutableHtml;
7 use ipl\Html\ValidHtml;
8
9 /**
10 * Describes how a decoration result should be transformed
11 */
12 enum Transformation
13 {
14 /** Add HTML to the end of the result */
15 case Append;
16
17 /** Prepend HTML to the beginning of the result */
18 case Prepend;
19
20 /** Set HTML as the container of the result */
21 case Wrap;
22
23 /**
24 * Transform the given results according to this case with the given HTML
25 *
26 * @param DecorationResult $result
27 * @param ValidHtml|MutableHtml $html
28 *
29 * @return DecorationResult
30 */
31 public function apply(DecorationResult $result, ValidHtml|MutableHtml $html): DecorationResult
32 {
33 return match ($this) {
34 self::Append => $result->append($html),
35 self::Prepend => $result->prepend($html),
36 self::Wrap => $result->wrap($html)
37 };
38 }
39 }