ComposeExporter::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Fowp\WordPressPluginRetriever\Export;
4
5
/**
6
 * This exporter combines a group of exporters that all are processed.
7
 *
8
 * @author [email protected]
9
 */
10
class ComposeExporter implements Exporter
11
{
12
    /**
13
     * List of exportes that are called
14
     *
15
     * @var Exporter[]
16
     */
17
    private array $exporters;
18
19
    /**
20
     * Add a new exporter to the composed exporter.
21
     *
22
     * @param Exporter $exporter
23
     * @return void
24
     */
25
    public function addExporter(Exporter $exporter): void
26
    {
27
        $this->exporters[] = $exporter;
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function process(array $pluginBlock, int $currentPage, int $maxPages): void
34
    {
35
        foreach ($this->exporters as $exporter) {
36
            $exporter->process($pluginBlock, $currentPage, $maxPages);
37
        }
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43
    public function finish(): void
44
    {
45
        foreach ($this->exporters as $exporter) {
46
            $exporter->finish();
47
        }
48
    }
49
}
50