| 1 |
<?php |
| 2 |
|
| 3 |
namespace SimpleAnalytics\Settings; |
| 4 |
|
| 5 |
use SimpleAnalytics\Settings\Concerns\WordPressPageIntegration; |
| 6 |
use SimpleAnalytics\Support\Str; |
| 7 |
|
| 8 |
class Page |
| 9 |
{ |
| 10 |
use WordPressPageIntegration; |
| 11 |
|
| 12 |
/** |
| 13 |
* @var string |
| 14 |
*/ |
| 15 |
protected $title; |
| 16 |
|
| 17 |
/** |
| 18 |
* @var string |
| 19 |
*/ |
| 20 |
protected $slug; |
| 21 |
|
| 22 |
/** @var Tab[] */ |
| 23 |
protected $tabs = []; |
| 24 |
|
| 25 |
public function __construct(string $title) |
| 26 |
{ |
| 27 |
$this->title = $title; |
| 28 |
} |
| 29 |
|
| 30 |
public static function title(string $title): self |
| 31 |
{ |
| 32 |
return new self($title); |
| 33 |
} |
| 34 |
|
| 35 |
public function slug(string $slug): self |
| 36 |
{ |
| 37 |
$this->slug = $slug; |
| 38 |
|
| 39 |
return $this; |
| 40 |
} |
| 41 |
|
| 42 |
public function tab(string $title, callable $callback): self |
| 43 |
{ |
| 44 |
$tab = new Tab($title, Str::slug($title)); |
| 45 |
$callback($tab); |
| 46 |
|
| 47 |
$this->tabs[] = $tab; |
| 48 |
|
| 49 |
return $this; |
| 50 |
} |
| 51 |
|
| 52 |
public function getTitle(): string |
| 53 |
{ |
| 54 |
return $this->title; |
| 55 |
} |
| 56 |
|
| 57 |
public function getSlug(): string |
| 58 |
{ |
| 59 |
return $this->slug; |
| 60 |
} |
| 61 |
|
| 62 |
public function getTabs(): array |
| 63 |
{ |
| 64 |
return $this->tabs; |
| 65 |
} |
| 66 |
} |
| 67 |
|