Conditions | 15 |
Paths | 17 |
Total Lines | 57 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
51 | protected function adjustGlobalQuery() |
||
52 | { |
||
53 | global $conf, $INPUT, $QUERY; |
||
54 | |||
55 | if ($INPUT->bool('searchPageForm')) { |
||
56 | return; |
||
57 | } |
||
58 | |||
59 | $Indexer = idx_get_indexer(); |
||
60 | $parsedQuery = ft_queryParser($Indexer, $QUERY); |
||
61 | |||
62 | if (empty($parsedQuery['ns']) && empty($parsedQuery['notns'])) { |
||
63 | if ($conf['search_limit_to_first_ns'] > 0) { |
||
64 | $searchOriginPage = $INPUT->str('from'); |
||
65 | if (getNS($searchOriginPage) !== false) { |
||
66 | $nsParts = explode(':', getNS($searchOriginPage)); |
||
67 | $ns = implode(':', array_slice($nsParts, 0, $conf['search_limit_to_first_ns'])); |
||
68 | $QUERY .= " @$ns"; |
||
69 | } |
||
70 | } |
||
71 | } |
||
72 | |||
73 | if ($conf['search_default_fragment_behaviour'] !== 'exact') { |
||
74 | if (empty(array_diff($parsedQuery['words'], $parsedQuery['and']))) { |
||
75 | if (strpos($QUERY, '*') === false) { |
||
76 | $queryParts = explode(' ', $QUERY); |
||
77 | $queryParts = array_map(function ($part) { |
||
78 | if (strpos($part, '@') === 0) { |
||
79 | return $part; |
||
80 | } |
||
81 | if (strpos($part, 'ns:') === 0) { |
||
82 | return $part; |
||
83 | } |
||
84 | if (strpos($part, '^') === 0) { |
||
85 | return $part; |
||
86 | } |
||
87 | if (strpos($part, '-ns:') === 0) { |
||
88 | return $part; |
||
89 | } |
||
90 | |||
91 | global $conf; |
||
92 | |||
93 | if ($conf['search_default_fragment_behaviour'] === 'starts_with') { |
||
94 | return $part . '*'; |
||
95 | } |
||
96 | if ($conf['search_default_fragment_behaviour'] === 'ends_with') { |
||
97 | return '*' . $part; |
||
98 | } |
||
99 | |||
100 | return '*' . $part . '*'; |
||
101 | |||
102 | }, $queryParts); |
||
103 | $QUERY = implode(' ', $queryParts); |
||
104 | } |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 |