Chain::append()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Aoe\Asdis\Content\Scraper;
3
4
use Aoe\Asdis\Content\Scraper\ScraperInterface;
5
use Aoe\Asdis\Domain\Model\Asset\Collection as AssetCollection;
6
7
/**
8
 * Scraper which chains other scrapers.
9
 */
10
class Chain extends \ArrayIterator implements ScraperInterface
11
{
12
    /**
13
     * Needs to be called due to an extbase bug.
14
     * Hides optional parameters of parent constructor.
15
     */
16 3
    public function __construct()
17
    {
18 3
        parent::__construct();
19 3
    }
20
21
    /**
22
     * @param \Aoe\Asdis\Content\Scraper\ScraperInterface $scraper
23
     */
24 2
    public function append($scraper)
25
    {
26 2
        parent::append($scraper);
27 2
    }
28
29
    /**
30
     * @param $content
31
     * @return \Aoe\Asdis\Domain\Model\Asset\Collection
32
     */
33 1
    public function scrape($content)
34
    {
35 1
        $assetCollection = new AssetCollection();
36 1
        foreach($this as $scraper) {
37
            /** @var \Aoe\Asdis\Content\Scraper\ScraperInterface $scraper */
38 1
            $assetCollection->merge($scraper->scrape($content));
39
        }
40 1
        return $assetCollection;
41
    }
42
}