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

JsonFeedPull::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 3
crap 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