| Conditions | 4 |
| Paths | 8 |
| Total Lines | 34 |
| Code Lines | 25 |
| Lines | 21 |
| Ratio | 61.76 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public static function searchFilter($searchterm) |
||
| 16 | { |
||
| 17 | $result = []; |
||
|
|
|||
| 18 | $result['searchterm'] = $searchterm; |
||
| 19 | |||
| 20 | preg_match_all('/maps:([0-9]+)/', $searchterm, $match); |
||
| 21 | View Code Duplication | foreach ($match[1] as $item) { |
|
| 22 | $game = Game::whereId($item)->first(); |
||
| 23 | $t['type'] = 'maps'; |
||
| 24 | $t['value'] = $item; |
||
| 25 | $result['filter'][] = $t; |
||
| 26 | $result['searchterm'] = str_replace($t['type'].':'.$t['value'], '', $result['searchterm']); |
||
| 27 | } |
||
| 28 | |||
| 29 | preg_match_all('/maps-min:([0-9]+)/', $searchterm, $match); |
||
| 30 | View Code Duplication | foreach ($match[1] as $item) { |
|
| 31 | $game = Game::whereId($item)->first(); |
||
| 32 | $t['type'] = 'maps-min'; |
||
| 33 | $t['value'] = $item; |
||
| 34 | $result['filter'][] = $t; |
||
| 35 | $result['searchterm'] = str_replace($t['type'].':'.$t['value'], '', $result['searchterm']); |
||
| 36 | } |
||
| 37 | |||
| 38 | preg_match_all('/maps-max:([0-9]+)/', $searchterm, $match); |
||
| 39 | View Code Duplication | foreach ($match[1] as $item) { |
|
| 40 | $game = Game::whereId($item)->first(); |
||
| 41 | $t['type'] = 'maps-max'; |
||
| 42 | $t['value'] = $item; |
||
| 43 | $result['filter'][] = $t; |
||
| 44 | $result['searchterm'] = str_replace($t['type'].':'.$t['value'], '', $result['searchterm']); |
||
| 45 | } |
||
| 46 | |||
| 47 | return $result; |
||
| 48 | } |
||
| 49 | } |
||
| 50 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.