ArrayExporter::process()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Fowp\WordPressPluginRetriever\Export;
4
5
/**
6
 * This exporter returns all retrieved plugins as an array.
7
 *
8
 * WARNING: This array can get quite big and can cause out of memory exceptions
9
 * if PHP only has 128 MB of memory. If you want to process the data it is recommended
10
 * to write a special exporter or to increase the usable memory.
11
 *
12
 * @author [email protected]
13
 */
14
class ArrayExporter implements Exporter
15
{
16
    /**
17
     * List of all plugins that where retrieved so far.
18
     *
19
     * @var array
20
     */
21
    private array $plugins = [];
22
23
    /**
24
     * @inheritDoc
25
     */
26
    public function process(array $pluginBlock, int $currentPage, int $maxPages): void
27
    {
28
        $this->plugins = array_merge($this->plugins, $pluginBlock);
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function finish(): void
35
    {
36
37
    }
38
39
    /**
40
     * Return all retrieved plugins in array structure.
41
     *
42
     * @return array
43
     */
44
    public function getArray(): array
45
    {
46
        return $this->plugins;
47
    }
48
}
49