summaryrefslogtreecommitdiff
blob: 7a99dda4d4635f1f1876233241d22e3118d6482e (plain)
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
<?php

/**
 * A class to combine multiple insertables suggesters.
 */
class CombinedInsertablesSuggester implements InsertablesSuggester {
	protected $suggesters = [];

	/**
	 * CombinedInsertablesSuggester constructor.
	 * @param array $suggesters Array of InsertablesSuggester objects to combine.
	 */
	public function __construct( $suggesters = [] ) {
		$this->suggesters = $suggesters;
	}

	public function getInsertables( $text ) {
		$insertables = [];
		foreach ( $this->suggesters as $suggester ) {
			$new = $suggester->getInsertables( $text );
			$insertables = array_merge( $insertables, $new );
		}

		return array_unique( $insertables, SORT_REGULAR );
	}
}