introductions-bucket.php
863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Yoast\WP\SEO\Introductions\Domain;
/**
* A collection domain object.
*/
class Introductions_Bucket {
/**
* Holds the introductions.
*
* @var Introduction_Item[]
*/
private $introductions;
/**
* The constructor.
*/
public function __construct() {
$this->introductions = [];
}
/**
* Adds an introduction to this bucket.
*
* @param Introduction_Item $introduction The introduction.
*
* @return void
*/
public function add_introduction( Introduction_Item $introduction ) {
$this->introductions[] = $introduction;
}
/**
* Returns the array representation of the introductions.
*
* @return array
*/
public function to_array() {
// No sorting here because that is done in JS.
return \array_map(
static function ( $item ) {
return $item->to_array();
},
$this->introductions
);
}
}