FeedProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace ExternalFeedParser\Providers;
4
5
use ExternalFeedParser\Contracts\Converter;
6
use ExternalFeedParser\Contracts\Provider;
7
use ExternalFeedParser\Contracts\PullProcessor;
8
use ExternalFeedParser\Entity\ExternalEntitiesCollection;
9
10
class FeedProvider implements Provider
11
{
12 2
    public function __construct(
13
        protected PullProcessor $pullProcessor,
14
        protected Converter     $converter,
15
    ) {
16 2
    }
17
18 2
    public function parse(): ExternalEntitiesCollection
19
    {
20 2
        $collection = ExternalEntitiesCollection::make();
21
22 2
        $this->pullProcessor->pull()
23 2
                            ->each(function ($item) use ($collection) {
24 2
                                $externalEntity = $this->converter->convert($item);
25 2
                                if ($externalEntity) {
26 2
                                    $collection->add($externalEntity);
27
                                }
28 2
                            });
29
30 2
        return $collection;
31
    }
32
}
33