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

ParserSearchDataTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A parserSearchData() 0 18 4
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
}