XmlFeedPull   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

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