Chain   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 31
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A scrape() 0 8 2
A __construct() 0 3 1
A append() 0 3 1
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
}