Passed
Push — feature/optimize ( 219eef...0e0305 )
by Fu
03:34
created

ParserSearchDataTrait::parserSearchData()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 9
nc 2
nop 0
dl 0
loc 18
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
4
namespace Modules\Core\Traits\Criteria;
5
6
7
use Exception;
8
9
trait ParserSearchDataTrait
10
{
11
    protected function parserSearchData()
12
    {
13
        $searchData = [];
14
15
        if (stripos($this->search, ':')) {
0 ignored issues
show
Bug introduced by
The property search does not exist on Modules\Core\Traits\Criteria\ParserSearchDataTrait. Did you mean searchData?
Loading history...
16
            $fields = explode(';', $this->search);
17
18
            foreach ($fields as $row) {
19
                try {
20
                    list($field, $value) = explode(':', $row);
21
                    $searchData[$field] = $value;
22
                } catch (Exception $e) {
23
                    //Surround offset error
24
                }
25
            }
26
        }
27
28
        $this->searchData = $searchData;
0 ignored issues
show
Bug Best Practice introduced by
The property searchData does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
    }
30
}