| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong |
| 4 |
namespace Yoast\WP\SEO\Llms_Txt\Infrastructure\Markdown_Services; |
| 5 |
|
| 6 |
use Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Sections\Description; |
| 7 |
use Yoast\WP\SEO\Surfaces\Meta_Surface; |
| 8 |
|
| 9 |
/** |
| 10 |
* The adapter of the description. |
| 11 |
*/ |
| 12 |
class Description_Adapter { |
| 13 |
|
| 14 |
/** |
| 15 |
* Holds the meta helper surface. |
| 16 |
* |
| 17 |
* @var Meta_Surface |
| 18 |
*/ |
| 19 |
private $meta; |
| 20 |
|
| 21 |
/** |
| 22 |
* Class constructor. |
| 23 |
* |
| 24 |
* @param Meta_Surface $meta The meta surface. |
| 25 |
*/ |
| 26 |
public function __construct( |
| 27 |
Meta_Surface $meta |
| 28 |
) { |
| 29 |
$this->meta = $meta; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Gets the description. |
| 34 |
* |
| 35 |
* @return Description The description. |
| 36 |
*/ |
| 37 |
public function get_description(): Description { |
| 38 |
$meta_description = $this->meta->for_home_page()->meta_description; |
| 39 |
|
| 40 |
// In a lot of cases, the homepage's meta description falls back to the site's tagline. |
| 41 |
// But that is already used for the title section, so let's try to not have duplicate content. |
| 42 |
if ( $meta_description === \get_bloginfo( 'description' ) ) { |
| 43 |
return new Description( '' ); |
| 44 |
} |
| 45 |
|
| 46 |
return new Description( $meta_description ); |
| 47 |
} |
| 48 |
} |
| 49 |
|