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

HasPendingRequest::preparePendingRequest()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 10
cc 3
nc 2
nop 0
crap 3
1
<?php
2
3
namespace ExternalFeedParser\Pull;
4
5
use Illuminate\Http\Client\PendingRequest;
6
use Illuminate\Support\Collection;
7
use Illuminate\Support\Facades\Http;
8
9
trait HasPendingRequest
10
{
11
    protected Collection $args;
12
13 2
    protected function preparePendingRequest(): PendingRequest
14
    {
15 2
        $pendingRequest = Http::timeout((int) $this->args->get('timeout', 20));
16
        if (
17 2
            ($headers = $this->args->get('headers'))
18 2
            && is_array($headers)
19
        ) {
20 1
            $pendingRequest->withHeaders($headers);
21
        }
22
23 2
        return $pendingRequest;
24
    }
25
}
26