identifier = (string)rand(1000, 9000); } public function startTab(string $title, bool $selected = false, string $attributes = '', bool $clickable = true): string { if ($this->opened) { $this->endTab(); } $this->opened = true; $attributes .= $clickable ? '' : 'data-empty="true"'; $attributes .= $selected ? 'data-selected="true"' : ''; $classLi = $clickable ? '' : 'tabs-title-empty'; $this->identifier = preg_replace('#[^a-z0-9]#is', '_', strtolower((string)$title)); $this->titles[] = '
  • '.$title.'
  • '; ob_start(); return $this->identifier; } public function endTab(): void { if (!$this->opened) { return; } $this->opened = false; $this->content[] = '
    '.ob_get_clean().'
    '; $this->tabNumber++; } public function addElementInBar(string $element, string $identifier = ''): void { $this->inBarElements[] = [ 'element' => $element, 'identifier' => $identifier, ]; } public function display(string $tabId): void { if ($this->opened) { $this->endTab(); } $tabSystem = ''; $tabSystem .= '
    '; $tabSystem .= implode('', $this->content); $tabSystem .= '
    '; echo $tabSystem; } }