Conditions | 17 |
Paths | 0 |
Total Lines | 167 |
Code Lines | 67 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 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 |
||
43 | public function main() { |
||
44 | |||
45 | switch ((string) $this->cli_args['_DEFAULT'][1]) { |
||
46 | |||
47 | // (Re-)Index a single document. |
||
48 | case 'index': |
||
49 | |||
50 | // Add command line arguments. |
||
51 | $this->cli_options[] = array ('-doc UID/URL', 'UID or (properly encoded) URL of the document.'); |
||
52 | |||
53 | $this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.'); |
||
54 | |||
55 | $this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.'); |
||
56 | |||
57 | // Check the command line arguments. |
||
58 | $this->cli_validateArgs(); |
||
59 | |||
60 | if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-doc'][0]) |
||
61 | && !\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($this->cli_args['-doc'][0])) { |
||
62 | |||
63 | $this->cli_echo('ERROR: "'.$this->cli_args['-doc'][0].'" is not a valid document UID or URL.'.LF, TRUE); |
||
64 | |||
65 | $this->return = 1; |
||
66 | |||
67 | } |
||
68 | |||
69 | if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-pid'][0])) { |
||
70 | |||
71 | $this->cli_echo('ERROR: "'.$this->cli_args['-pid'][0].'" is not a valid page UID.'.LF, TRUE); |
||
72 | |||
73 | $this->return = 1; |
||
74 | |||
75 | } |
||
76 | |||
77 | if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-core'][0])) { |
||
78 | |||
79 | $this->cli_echo('ERROR: "'.$this->cli_args['-core'][0].'" is not a valid core UID.'.LF, TRUE); |
||
80 | |||
81 | $this->return = 1; |
||
82 | |||
83 | } |
||
84 | |||
85 | if ($this->return > 0) { |
||
86 | |||
87 | break; |
||
88 | |||
89 | } |
||
90 | |||
91 | // Get the document... |
||
92 | $doc = & tx_dlf_document::getInstance($this->cli_args['-doc'][0], $this->cli_args['-pid'][0], TRUE); |
||
93 | |||
94 | if ($doc->ready) { |
||
95 | |||
96 | // ...and save it to the database... |
||
97 | if (!$doc->save(intval($this->cli_args['-pid'][0]), intval($this->cli_args['-core'][0]))) { |
||
98 | |||
99 | $this->cli_echo('ERROR: Document "'.$this->cli_args['-doc'][0].'" not saved and indexed.'.LF, TRUE); |
||
100 | |||
101 | $this->return = 1; |
||
102 | |||
103 | } |
||
104 | |||
105 | } else { |
||
106 | |||
107 | $this->cli_echo('ERROR: Document "'.$this->cli_args['-doc'][0].'" could not be loaded.'.LF, TRUE); |
||
108 | |||
109 | $this->return = 1; |
||
110 | |||
111 | } |
||
112 | |||
113 | break; |
||
114 | |||
115 | // Re-index all documents of a collection. |
||
116 | case 'reindex': |
||
117 | |||
118 | // Add command line arguments. |
||
119 | $this->cli_options[] = array ('-coll UID', 'UID of the collection.'); |
||
120 | |||
121 | $this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.'); |
||
122 | |||
123 | $this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.'); |
||
124 | |||
125 | // Check the command line arguments. |
||
126 | $this->cli_validateArgs(); |
||
127 | |||
128 | if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-coll'][0])) { |
||
129 | |||
130 | $this->cli_echo('ERROR: "'.$this->cli_args['-coll'][0].'" is not a valid collection UID.'.LF, TRUE); |
||
131 | |||
132 | $this->return = 1; |
||
133 | |||
134 | } |
||
135 | |||
136 | if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-pid'][0])) { |
||
137 | |||
138 | $this->cli_echo('ERROR: "'.$this->cli_args['-pid'][0].'" is not a valid page UID.'.LF, TRUE); |
||
139 | |||
140 | $this->return = 1; |
||
141 | |||
142 | } |
||
143 | |||
144 | if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-core'][0])) { |
||
145 | |||
146 | $this->cli_echo('ERROR: "'.$this->cli_args['-core'][0].'" is not a valid core UID.'.LF, TRUE); |
||
147 | |||
148 | $this->return = 1; |
||
149 | |||
150 | } |
||
151 | |||
152 | if ($this->return > 0) { |
||
153 | |||
154 | break; |
||
155 | |||
156 | } |
||
157 | |||
158 | // Get the collection. |
||
159 | $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( |
||
160 | 'tx_dlf_documents.uid AS uid', |
||
161 | 'tx_dlf_documents', |
||
162 | 'tx_dlf_relations', |
||
163 | 'tx_dlf_collections', |
||
164 | 'AND tx_dlf_collections.uid='.intval($this->cli_args['-coll'][0]).' AND tx_dlf_collections.pid='.intval($this->cli_args['-pid'][0]).' AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations').tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'), |
||
165 | '', |
||
166 | '', |
||
167 | '' |
||
168 | ); |
||
169 | |||
170 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
||
171 | |||
172 | // Get the document... |
||
173 | $doc = & tx_dlf_document::getInstance($resArray['uid'], $this->cli_args['-pid'][0], TRUE); |
||
174 | |||
175 | if ($doc->ready) { |
||
176 | |||
177 | // ...and save it to the database... |
||
178 | if (!$doc->save(intval($this->cli_args['-pid'][0]), intval($this->cli_args['-core'][0]))) { |
||
179 | |||
180 | $this->cli_echo('ERROR: Document "'.$resArray['uid'].'" not saved and indexed.'.LF, TRUE); |
||
181 | |||
182 | $this->return = 1; |
||
183 | |||
184 | } |
||
185 | |||
186 | } else { |
||
187 | |||
188 | $this->cli_echo('ERROR: Document "'.$resArray['uid'].'" could not be loaded.'.LF, TRUE); |
||
189 | |||
190 | $this->return = 1; |
||
191 | |||
192 | } |
||
193 | |||
194 | // Clear document registry to prevent memory exhaustion. |
||
195 | tx_dlf_document::clearRegistry(); |
||
196 | |||
197 | } |
||
198 | |||
199 | break; |
||
200 | |||
201 | default: |
||
202 | |||
203 | $this->cli_help(); |
||
204 | |||
205 | break; |
||
206 | |||
207 | } |
||
208 | |||
209 | exit ($this->return); |
||
210 | |||
236 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths