PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 19.0 All 129 releases
wordpress-seo / src / schema-aggregator / domain / schema-piece-collection.php

schema-piece-collection.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at src/schema-aggregator/domain/schema-piece-collection.php

49 lines 961 B
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\Schema_Aggregator\Domain;
5
6 /**
7 * Type-safe collection for Schema_Piece objects.
8 */
9 class Schema_Piece_Collection {
10
11 /**
12 * The schema pieces.
13 *
14 * @var array<Schema_Piece>
15 */
16 private $pieces = [];
17
18 /**
19 * Class constructor.
20 *
21 * @param array<Schema_Piece> $pieces Optional array of Schema_Piece objects.
22 */
23 public function __construct( array $pieces = [] ) {
24 foreach ( $pieces as $piece ) {
25 $this->add( $piece );
26 }
27 }
28
29 /**
30 * Adds a schema piece to the collection.
31 *
32 * @param Schema_Piece $piece The schema piece to add.
33 *
34 * @return void
35 */
36 public function add( Schema_Piece $piece ): void {
37 $this->pieces[] = $piece;
38 }
39
40 /**
41 * Gets all schema pieces as an array.
42 *
43 * @return array<Schema_Piece> The schema pieces.
44 */
45 public function to_array(): array {
46 return $this->pieces;
47 }
48 }
49