# simpleanalytics/1.67/src/Settings/Tab.php

Simple Analytics, version 1.67. 115 lines.

- Page: https://pluginprobe.com/plugins/simpleanalytics/1.67/code/src/Settings/Tab.php
- Raw: https://pluginprobe.com/plugins/simpleanalytics/1.67/raw/src/Settings/Tab.php
- Modified: 2024-09-13T11:41:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/simpleanalytics/1.67/code/src/Settings/Tab.php#L10-L20`.

```php
<?php

namespace SimpleAnalytics\Settings;

use SimpleAnalytics\Support\SvgIcon;

class Tab
{
    use Concerns\HasDocs;
    use Concerns\ManagesBlocks;

    /**
     * @readonly
     * @var string
     */
    protected $name;

    /**
     * @readonly
     * @var string
     */
    protected $slug;

    /**
     * @var \SimpleAnalytics\Support\SvgIcon|null
     */
    protected $icon;

    /**
     * @var string|null
     */
    protected $title;

    /** @var Block[] */
    protected $blocks = [];

    public function __construct(string $name, string $slug)
    {
        $this->name = $name;
        $this->slug = $slug;
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function getSlug(): string
    {
        return $this->slug;
    }

    public function icon(SvgIcon $icon): self
    {
        $this->icon = $icon;

        return $this;
    }

    public function getIcon(): ?SvgIcon
    {
        return $this->icon;
    }

    public function title(string $title): self
    {
        $this->title = $title;

        return $this;
    }

    protected function addBlock(Block $block): self
    {
        $this->blocks[] = $block;
        return $this;
    }

    public function getBlocks(): array
    {
        return $this->blocks;
    }

    public function render(): void
    {
        ?>
        <div class="grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
            <?php if (isset($this->title) || isset($this->description)): ?>
                <div class="sm:col-span-4">
                    <?php if (isset($this->title)): ?>
                        <h1 class="text-sm font-medium leading-6 text-gray-900">
                            <?php echo esc_html($this->title); ?>
                            <?php if (isset($this->docs)): ?>
                                <a href="<?php echo esc_url($this->docs); ?>" target="_blank"
                                   class="text-primary">(docs)</a>
                            <?php endif; ?>
                        </h1>
                    <?php endif; ?>
                    <?php if (isset($this->description)): ?>
                        <p class="mt-2 text-sm text-gray-500">
                            <?php echo esc_html($this->description); ?>
                        </p>
                    <?php endif; ?>
                </div>
            <?php endif; ?>

            <?php foreach ($this->getBlocks() as $block): ?>
                <div class="sm:col-span-4">
                    <?php $block->render(); ?>
                </div>
            <?php endforeach; ?>
        </div>
        <?php
    }
}

```
