File: D:/HostingSpaces/SBogers10/helder.komma.pro/app/Komma/Kms/Core/Sections/SectionTabsCollection.php
<?php namespace App\Komma\Kms\Core\Sections;
/**
* Class SectionTabs
* @package App\Komma\Kms\Core\Sections
*/
class SectionTabsCollection implements SectionTabsCollectionInterface
{
/**
* @var $tabs SectionTab[];
*/
protected $tabs = [];
/**
* Looks trough it's collection of tabs and returns the tab with the name you specify.
* If there is not tab with the name you'd specify it will create a new one and use the group you can specify.
*
* @param string $name
* @param string $group
* @return SectionTab|null
*/
public function getOrCreateTab(string $name, string $group = '')
{
$tab = $this->getTabBySlug($name);
if (!$tab) return $this->tabs[] = new SectionTab($name, str_slug($name), $group);
return $tab;
}
/**
* @return SectionTab[]
*/
public function getTabs()
{
return $this->tabs;
}
/**
* Deletes all tabs
*
* @return void
*/
public function clearTabs()
{
$this->tabs = [];
}
/**
* Returns a tab where its slug matches the one you pass.
* If there is no tag with the slug specified, null is returned instead.
*
* @param $slug
* @return SectionTab|null
*/
protected function getTabBySlug($slug)
{
foreach ($this->tabs as $tab) {
if ($tab->getSlug() == str_slug($slug)) return $tab;
}
return null;
}
}