ts3phpframework
Loading...
Searching...
No Matches
Text.php
Go to the documentation of this file.
1<?php
2
3namespace PlanetTeamSpeak\TeamSpeak3Framework\Viewer;
4
5use PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper;
6use PlanetTeamSpeak\TeamSpeak3Framework\Node\Node;
7
13class Text implements ViewerInterface
14{
20 protected string $pattern = "%0%1 %2\n";
21
29 public function fetchObject(Node $node, array $siblings = []): string
30 {
31 $this->currObj = $node;
32 $this->currSib = $siblings;
33
34 $args = [
35 $this->getPrefix(),
36 $this->getCorpusIcon(),
37 $this->getCorpusName(),
38 ];
39
40 return StringHelper::factory($this->pattern)->arg($args);
41 }
42
48 protected function getPrefix(): string
49 {
50 $prefix = "";
51
52 if (count($this->currSib)) {
53 $last = array_pop($this->currSib);
54
55 foreach ($this->currSib as $sibling) {
56 $prefix .= ($sibling) ? "| " : " ";
57 }
58
59 $prefix .= ($last) ? "\\-" : "|-";
60 }
61
62 return $prefix;
63 }
64
71 protected function getCorpusIcon(): string
72 {
73 return $this->currObj->getSymbol();
74 }
75
82 protected function getCorpusName(): string
83 {
84 return $this->currObj;
85 }
86}
fetchObject(Node $node, array $siblings=[])
Definition Text.php:29