Conditions | 15 |
Paths | 17 |
Total Lines | 56 |
Code Lines | 33 |
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 |
||
79 | protected function adjustGlobalQuery() |
||
80 | { |
||
81 | global $conf, $INPUT, $QUERY, $ID; |
||
82 | |||
83 | if ($INPUT->bool('sf')) { |
||
84 | return; |
||
85 | } |
||
86 | |||
87 | $Indexer = idx_get_indexer(); |
||
88 | $parsedQuery = ft_queryParser($Indexer, $QUERY); |
||
89 | |||
90 | if (empty($parsedQuery['ns']) && empty($parsedQuery['notns'])) { |
||
91 | if ($conf['search_limit_to_first_ns'] > 0) { |
||
92 | if (getNS($ID) !== false) { |
||
93 | $nsParts = explode(':', getNS($ID)); |
||
94 | $ns = implode(':', array_slice($nsParts, 0, $conf['search_limit_to_first_ns'])); |
||
95 | $QUERY .= " @$ns"; |
||
96 | } |
||
97 | } |
||
98 | } |
||
99 | |||
100 | if ($conf['search_default_fragment_behaviour'] !== 'exact') { |
||
101 | if (empty(array_diff($parsedQuery['words'], $parsedQuery['and']))) { |
||
102 | if (strpos($QUERY, '*') === false) { |
||
103 | $queryParts = explode(' ', $QUERY); |
||
104 | $queryParts = array_map(function ($part) { |
||
105 | if (strpos($part, '@') === 0) { |
||
106 | return $part; |
||
107 | } |
||
108 | if (strpos($part, 'ns:') === 0) { |
||
109 | return $part; |
||
110 | } |
||
111 | if (strpos($part, '^') === 0) { |
||
112 | return $part; |
||
113 | } |
||
114 | if (strpos($part, '-ns:') === 0) { |
||
115 | return $part; |
||
116 | } |
||
117 | |||
118 | global $conf; |
||
119 | |||
120 | if ($conf['search_default_fragment_behaviour'] === 'starts_with') { |
||
121 | return $part . '*'; |
||
122 | } |
||
123 | if ($conf['search_default_fragment_behaviour'] === 'ends_with') { |
||
124 | return '*' . $part; |
||
125 | } |
||
126 | |||
127 | return '*' . $part . '*'; |
||
128 | |||
129 | }, $queryParts); |
||
130 | $QUERY = implode(' ', $queryParts); |
||
131 | } |
||
132 | } |
||
133 | } |
||
134 | } |
||
135 | } |
||
136 |