HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/pietvanmierlo/stempelbv.nl/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;
    }

}