| Conditions | 6 |
| Paths | 18 |
| Total Lines | 27 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 6 |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | 54 | public function transform($item) |
|
| 32 | { |
||
| 33 | // Menu items that aren't a search bar should be ignored. |
||
| 34 | |||
| 35 | 54 | $isSearchBar = NavbarItemHelper::isSearch($item) |
|
| 36 | 54 | || SidebarItemHelper::isSearch($item); |
|
| 37 | |||
| 38 | 54 | if (! $isSearchBar) { |
|
| 39 | 52 | return $item; |
|
| 40 | } |
||
| 41 | |||
| 42 | // Setup the search bar method attribute. |
||
| 43 | |||
| 44 | 3 | $isValidMethod = isset($item['method']) |
|
| 45 | 3 | && in_array(strtolower($item['method']), ['post', 'get']); |
|
| 46 | |||
| 47 | 3 | if (! $isValidMethod) { |
|
| 48 | 3 | $item['method'] = $this->defMethod; |
|
| 49 | } |
||
| 50 | |||
| 51 | // Setup the search bar input name attribute. |
||
| 52 | |||
| 53 | 3 | if (empty($item['input_name'])) { |
|
| 54 | 3 | $item['input_name'] = $this->defName; |
|
| 55 | } |
||
| 56 | |||
| 57 | 3 | return $item; |
|
| 58 | } |
||
| 60 |