Passed
Push — main ( 528a1a...9cd807 )
by Yaroslav
13:38
created

HasRequestParams::getRequestParams()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 7
nc 4
nop 0
dl 0
loc 13
ccs 0
cts 8
cp 0
crap 20
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace IproSync\Console\Commands\Traits;
4
5
trait HasRequestParams
6
{
7
    protected function getRequestParams(): array
8
    {
9
        $requestParams    = [];
10
        $requestParamsStr = $this->option('request_params');
0 ignored issues
show
Bug introduced by
It seems like option() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

10
        /** @scrutinizer ignore-call */ 
11
        $requestParamsStr = $this->option('request_params');
Loading history...
11
        if ($requestParamsStr && is_string($requestParamsStr)) {
12
            parse_str(urldecode($requestParamsStr), $requestParams);
13
        }
14
15
        if(!is_array($requestParams)) {
16
            return [];
17
        }
18
19
        return $requestParams;
20
    }
21
}
22