Passed
Push — master ( 192151...016084 )
by Yaroslav
02:38
created

JsonFeedPull   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pull() 0 7 1
A __construct() 0 6 1
1
<?php
2
3
namespace ExternalFeedParser\Pull;
4
5
use ExternalFeedParser\Contracts\PullProcessor;
6
use Illuminate\Support\Collection;
7
8
class JsonFeedPull implements PullProcessor
9
{
10
    use HasPendingRequest;
11
12 1
    public function __construct(
13
        protected string  $url,
14
        protected ?string $listingKey = null,
15
        array             $args = [],
16
    ) {
17 1
        $this->args = collect($args);
18 1
    }
19
20
21 1
    public function pull(): Collection
22
    {
23 1
        $response = $this->preparePendingRequest()->get($this->url);
24
25 1
        $data = $response->json($this->listingKey, []);
26
27 1
        return collect($data);
28
    }
29
}
30