1 | <?php |
||
12 | class ConcatenationAdapter implements AdapterInterface |
||
13 | { |
||
14 | /** |
||
15 | * @var AdapterInterface[] List of adapters |
||
16 | */ |
||
17 | protected $adapters; |
||
18 | |||
19 | /** |
||
20 | * @var int[]|null Cache of the numbers of results of the adapters. The indexes correspond the indexes of the |
||
21 | * `adapters` property. |
||
22 | */ |
||
23 | protected $adaptersNbResultsCache; |
||
24 | |||
25 | /** |
||
26 | * @param AdapterInterface[] $adapters |
||
27 | * @throws InvalidArgumentException |
||
28 | */ |
||
29 | 4 | public function __construct(array $adapters) |
|
30 | { |
||
31 | 4 | foreach ($adapters as $index => $adapter) { |
|
32 | 4 | if (!($adapter instanceof AdapterInterface)) { |
|
33 | 1 | throw new InvalidArgumentException(sprintf( |
|
34 | 1 | 'Argument $adapters[%s] expected to be a \Pagerfanta\Adapter\AdapterInterface instance, a %s given', |
|
35 | $index, |
||
36 | 1 | is_object($adapter) ? sprintf('%s instance', get_class($adapter)) : gettype($adapter) |
|
37 | )); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | 4 | $this->adapters = $adapters; |
|
42 | 4 | } |
|
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 1 | public function getNbResults() |
|
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | * @return array |
||
59 | */ |
||
60 | 2 | public function getSlice($offset, $length) |
|
112 | |||
113 | /** |
||
114 | * Refreshes the cache of the numbers of results of the adapters. |
||
115 | */ |
||
116 | 3 | protected function refreshAdaptersNbResults() |
|
126 | } |
||
127 |