PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.6
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.6
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 / llms-txt / infrastructure / content / post-collection-factory.php

post-collection-factory.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.6, at src/llms-txt/infrastructure/content/post-collection-factory.php

58 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4 namespace Yoast\WP\SEO\Llms_Txt\Infrastructure\Content;
5
6 use Exception;
7 use Yoast\WP\SEO\Llms_Txt\Domain\content\Post_Collection_Interface;
8
9 /**
10 * The factory to determine which post collection class to use.
11 */
12 class Post_Collection_Factory {
13
14 /**
15 * The manual post collection.
16 *
17 * @var Manual_Post_Collection
18 */
19 private $manual_post_collection;
20
21 /**
22 * The automatic post collection.
23 *
24 * @var Automatic_Post_Collection
25 */
26 private $automatic_post_collection;
27
28 /**
29 * Constructor.
30 *
31 * @param Manual_Post_Collection $manual_post_collection The manual post collection.
32 * @param Automatic_Post_Collection $automatic_post_collection The automatic post collection.
33 */
34 public function __construct( Manual_Post_Collection $manual_post_collection, Automatic_Post_Collection $automatic_post_collection ) {
35 $this->manual_post_collection = $manual_post_collection;
36 $this->automatic_post_collection = $automatic_post_collection;
37 }
38
39 /**
40 * Determines which collection class is needed.
41 *
42 * @param string $collection_type The type of collection.
43 *
44 * @throws Exception Throws when an invalid type is given.
45 * @return Post_Collection_Interface
46 */
47 public function get_post_collection( string $collection_type ): Post_Collection_Interface {
48 switch ( $collection_type ) {
49 case 'manual':
50 return $this->manual_post_collection;
51 case 'auto':
52 return $this->automatic_post_collection;
53 default:
54 throw new Exception( 'Invalid collection type provided' );
55 }
56 }
57 }
58