| 1 | <?php |
||
| 20 | { |
||
| 21 | public const NAME = 'highlight'; |
||
| 22 | |||
| 23 | private ?BuilderInterface $highlight = null; |
||
|
|
|||
| 24 | |||
| 25 | private ?string $key = null; |
||
| 26 | |||
| 27 | public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []) |
||
| 28 | { |
||
| 29 | if ($this->highlight) { |
||
| 30 | return $this->highlight->toArray(); |
||
| 31 | } |
||
| 32 | |||
| 33 | return null; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function add(BuilderInterface $builder, ?string $key = null): ?string |
||
| 37 | { |
||
| 38 | if ($this->highlight) { |
||
| 39 | throw new \OverflowException('Only one highlight can be set'); |
||
| 40 | } |
||
| 41 | |||
| 42 | $this->key = $key; |
||
| 43 | $this->highlight = $builder; |
||
| 44 | |||
| 45 | return $key; |
||
| 46 | } |
||
| 47 | |||
| 48 | public function getAll(?string $boolType = null): array |
||
| 49 | { |
||
| 50 | return [$this->key => $this->highlight]; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function getHighlight(): ?BuilderInterface |
||
| 54 | { |
||
| 55 | return $this->highlight; |
||
| 56 | } |
||
| 57 | } |
||
| 58 |