FeedProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parse() 0 13 2
A __construct() 0 4 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