| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong |
| 4 |
namespace Yoast\WP\SEO\Editors\Domain\Seo; |
| 5 |
|
| 6 |
/** |
| 7 |
* This class describes the title SEO data. |
| 8 |
*/ |
| 9 |
class Title implements Seo_Plugin_Data_Interface { |
| 10 |
|
| 11 |
/** |
| 12 |
* The title template. |
| 13 |
* |
| 14 |
* @var string |
| 15 |
*/ |
| 16 |
private $title_template; |
| 17 |
|
| 18 |
/** |
| 19 |
* The title template without the fallback. |
| 20 |
* |
| 21 |
* @var string |
| 22 |
*/ |
| 23 |
private $title_template_no_fallback; |
| 24 |
|
| 25 |
/** |
| 26 |
* The constructor. |
| 27 |
* |
| 28 |
* @param string $title_template The title template. |
| 29 |
* @param string $title_template_no_fallback The title template without the fallback. |
| 30 |
*/ |
| 31 |
public function __construct( string $title_template, string $title_template_no_fallback ) { |
| 32 |
$this->title_template = $title_template; |
| 33 |
$this->title_template_no_fallback = $title_template_no_fallback; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Returns the data as an array format. |
| 38 |
* |
| 39 |
* @return array<string> |
| 40 |
*/ |
| 41 |
public function to_array(): array { |
| 42 |
return [ |
| 43 |
'title_template' => $this->title_template, |
| 44 |
'title_template_no_fallback' => $this->title_template_no_fallback, |
| 45 |
]; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Returns the data as an array format meant for legacy use. |
| 50 |
* |
| 51 |
* @return array<string> |
| 52 |
*/ |
| 53 |
public function to_legacy_array(): array { |
| 54 |
return [ |
| 55 |
'title_template' => $this->title_template, |
| 56 |
'title_template_no_fallback' => $this->title_template_no_fallback, |
| 57 |
]; |
| 58 |
} |
| 59 |
} |
| 60 |
|