PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.7
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.7
28.6 28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 All 130 releases
wordpress-seo / src / schema-aggregator / application / enhancement / schema-enhancement-factory.php

schema-enhancement-factory.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.7, at src/schema-aggregator/application/enhancement/schema-enhancement-factory.php

60 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
3 namespace Yoast\WP\SEO\Schema_Aggregator\Application\Enhancement;
4
5 use Yoast\WP\SEO\Schema_Aggregator\Domain\Enhancement\Schema_Enhancement_Interface;
6
7 /**
8 * The Schema_Enhancement_Factory.
9 */
10 class Schema_Enhancement_Factory {
11
12 /**
13 * The schema enhancer.
14 *
15 * @var Article_Schema_Enhancer
16 */
17 private $article_schema_enhancer;
18
19 /**
20 * The person schema enhancer.
21 *
22 * @var Person_Schema_Enhancer
23 */
24 private $person_schema_enhancer;
25
26 /**
27 * Constructor.
28 *
29 * @param Article_Schema_Enhancer $article_schema_enhancer The article schema enhancer.
30 * @param Person_Schema_Enhancer $person_schema_enhancer The person schema enhancer.
31 */
32 public function __construct(
33 Article_Schema_Enhancer $article_schema_enhancer,
34 Person_Schema_Enhancer $person_schema_enhancer
35 ) {
36 $this->article_schema_enhancer = $article_schema_enhancer;
37 $this->person_schema_enhancer = $person_schema_enhancer;
38 }
39
40 /**
41 * Returns the appropriate schema enhancer based on the schema type.
42 *
43 * @param array<string> $schema_types The types of schema (e.g., 'Article', 'Person').
44 *
45 * @return Schema_Enhancement_Interface|null The corresponding schema enhancer or null if none exists.
46 */
47 public function get_enhancer( array $schema_types ): ?Schema_Enhancement_Interface {
48 foreach ( $schema_types as $schema_type_value ) {
49 switch ( $schema_type_value ) {
50 case 'Article':
51 return $this->article_schema_enhancer;
52 case 'Person':
53 return $this->person_schema_enhancer;
54 default:
55 return null; // No enhancer available for the given schema type.
56 }
57 }
58 }
59 }
60