Complex classes like GarbageCollector often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use GarbageCollector, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 44 | class GarbageCollector extends AbstractDataHandlerListener implements SingletonInterface  | 
            ||
| 45 | { | 
            ||
| 46 | /**  | 
            ||
| 47 | * @var array  | 
            ||
| 48 | */  | 
            ||
| 49 | protected $trackedRecords = [];  | 
            ||
| 50 | |||
| 51 | /**  | 
            ||
| 52 | * @var TCAService  | 
            ||
| 53 | */  | 
            ||
| 54 | protected $tcaService;  | 
            ||
| 55 | |||
| 56 | /**  | 
            ||
| 57 | * GarbageCollector constructor.  | 
            ||
| 58 | * @param TCAService|null $TCAService  | 
            ||
| 59 | */  | 
            ||
| 60 | 4 | public function __construct(TCAService $TCAService = null)  | 
            |
| 64 | |||
| 65 | /**  | 
            ||
| 66 | * Hooks into TCE main and tracks record deletion commands.  | 
            ||
| 67 | *  | 
            ||
| 68 | * @param string $command The command.  | 
            ||
| 69 | * @param string $table The table the record belongs to  | 
            ||
| 70 | * @param int $uid The record's uid  | 
            ||
| 71 | * @param string $value Not used  | 
            ||
| 72 | * @param DataHandler $tceMain TYPO3 Core Engine parent object, not used  | 
            ||
| 73 | * @return void  | 
            ||
| 74 | */  | 
            ||
| 75 | public function processCmdmap_preProcess(  | 
            ||
| 91 | |||
| 92 | /**  | 
            ||
| 93 | * Holds the configuration when a recursive page queing should be triggered.  | 
            ||
| 94 | *  | 
            ||
| 95 | * @var array  | 
            ||
| 96 | * @return array  | 
            ||
| 97 | */  | 
            ||
| 98 | 2 | protected function getUpdateSubPagesRecursiveTriggerConfiguration()  | 
            |
| 113 | |||
| 114 | /**  | 
            ||
| 115 | * Tracks down index documents belonging to a particular record or page and  | 
            ||
| 116 | * removes them from the index and the Index Queue.  | 
            ||
| 117 | *  | 
            ||
| 118 | * @param string $table The record's table name.  | 
            ||
| 119 | * @param int $uid The record's uid.  | 
            ||
| 120 | * @throws \UnexpectedValueException if a hook object does not implement interface \ApacheSolrForTypo3\Solr\GarbageCollectorPostProcessor  | 
            ||
| 121 | */  | 
            ||
| 122 | 4 | public function collectGarbage($table, $uid)  | 
            |
| 146 | |||
| 147 | /**  | 
            ||
| 148 | * Tracks down index documents belonging to a particular page and  | 
            ||
| 149 | * removes them from the index and the Index Queue.  | 
            ||
| 150 | *  | 
            ||
| 151 | * @param string $table The record's table name.  | 
            ||
| 152 | * @param int $uid The record's uid.  | 
            ||
| 153 | */  | 
            ||
| 154 | 4 | protected function collectPageGarbage($table, $uid)  | 
            |
| 185 | |||
| 186 | /**  | 
            ||
| 187 | * @param string $table  | 
            ||
| 188 | * @param int $uid  | 
            ||
| 189 | * @param array $changedFields  | 
            ||
| 190 | */  | 
            ||
| 191 | 2 | protected function deleteSubpagesWhenExtendToSubpagesIsSet($table, $uid, $changedFields)  | 
            |
| 206 | |||
| 207 | /**  | 
            ||
| 208 | * Deletes index documents for a given record identification.  | 
            ||
| 209 | *  | 
            ||
| 210 | * @param string $table The record's table name.  | 
            ||
| 211 | * @param int $uid The record's uid.  | 
            ||
| 212 | */  | 
            ||
| 213 | 4 | protected function deleteIndexDocuments($table, $uid)  | 
            |
| 235 | |||
| 236 | /**  | 
            ||
| 237 | * Tracks down index documents belonging to a particular record and  | 
            ||
| 238 | * removes them from the index and the Index Queue.  | 
            ||
| 239 | *  | 
            ||
| 240 | * @param string $table The record's table name.  | 
            ||
| 241 | * @param int $uid The record's uid.  | 
            ||
| 242 | */  | 
            ||
| 243 | protected function collectRecordGarbage($table, $uid)  | 
            ||
| 248 | |||
| 249 | // methods checking whether to trigger garbage collection  | 
            ||
| 250 | |||
| 251 | /**  | 
            ||
| 252 | * Hooks into TCE main and tracks page move commands.  | 
            ||
| 253 | *  | 
            ||
| 254 | * @param string $command The command.  | 
            ||
| 255 | * @param string $table The table the record belongs to  | 
            ||
| 256 | * @param int $uid The record's uid  | 
            ||
| 257 | * @param string $value Not used  | 
            ||
| 258 | * @param DataHandler $tceMain TYPO3 Core Engine parent object, not used  | 
            ||
| 259 | */  | 
            ||
| 260 | public function processCmdmap_postProcess(  | 
            ||
| 280 | |||
| 281 | /**  | 
            ||
| 282 | * Hooks into TCE main and tracks changed records. In this case the current  | 
            ||
| 283 | * record's values are stored to do a change comparison later on for fields  | 
            ||
| 284 | * like fe_group.  | 
            ||
| 285 | *  | 
            ||
| 286 | * @param array $incomingFields An array of incoming fields, new or changed, not used  | 
            ||
| 287 | * @param string $table The table the record belongs to  | 
            ||
| 288 | * @param mixed $uid The record's uid, [integer] or [string] (like 'NEW...')  | 
            ||
| 289 | * @param DataHandler $tceMain TYPO3 Core Engine parent object, not used  | 
            ||
| 290 | */  | 
            ||
| 291 | public function processDatamap_preProcessFieldArray(  | 
            ||
| 324 | |||
| 325 | /**  | 
            ||
| 326 | * Hooks into TCE Main and watches all record updates. If a change is  | 
            ||
| 327 | * detected that would remove the record from the website, we try to find  | 
            ||
| 328 | * related documents and remove them from the index.  | 
            ||
| 329 | *  | 
            ||
| 330 | * @param string $status Status of the current operation, 'new' or 'update'  | 
            ||
| 331 | * @param string $table The table the record belongs to  | 
            ||
| 332 | * @param mixed $uid The record's uid, [integer] or [string] (like 'NEW...')  | 
            ||
| 333 | * @param array $fields The record's data, not used  | 
            ||
| 334 | * @param DataHandler $tceMain TYPO3 Core Engine parent object, not used  | 
            ||
| 335 | */  | 
            ||
| 336 | 2 | public function processDatamap_afterDatabaseOperations(  | 
            |
| 374 | |||
| 375 | /**  | 
            ||
| 376 | * Checks whether the record is in the Index Queue and whether it has been  | 
            ||
| 377 | * indexed already.  | 
            ||
| 378 | *  | 
            ||
| 379 | * @param string $table The table name.  | 
            ||
| 380 | * @param array $record An array with record fields that may affect visibility.  | 
            ||
| 381 | * @return bool True if the record is marked as being indexed  | 
            ||
| 382 | */  | 
            ||
| 383 | protected function isMarkedAsIndexed($table, $record)  | 
            ||
| 387 | |||
| 388 | /**  | 
            ||
| 389 | * @return Queue  | 
            ||
| 390 | */  | 
            ||
| 391 | 4 | private function getIndexQueue()  | 
            |
| 395 | |||
| 396 | /**  | 
            ||
| 397 | * Checks whether the a frontend group field exists for the record and if so  | 
            ||
| 398 | * whether groups have been removed from accessing the record thus making  | 
            ||
| 399 | * the record invisible to at least some people.  | 
            ||
| 400 | *  | 
            ||
| 401 | * @param string $table The table name.  | 
            ||
| 402 | * @param array $record An array with record fields that may affect visibility.  | 
            ||
| 403 | * @return bool TRUE if frontend groups have been removed from access to the record, FALSE otherwise.  | 
            ||
| 404 | */  | 
            ||
| 405 | protected function hasFrontendGroupsRemoved($table, $record)  | 
            ||
| 424 | |||
| 425 | /**  | 
            ||
| 426 | * Checks whether the page has been excluded from searching.  | 
            ||
| 427 | *  | 
            ||
| 428 | * @param array $record An array with record fields that may affect visibility.  | 
            ||
| 429 | * @return bool True if the page has been excluded from searching, FALSE otherwise  | 
            ||
| 430 | */  | 
            ||
| 431 | protected function isPageExcludedFromSearch($record)  | 
            ||
| 435 | |||
| 436 | /**  | 
            ||
| 437 | * Checks whether a page has a page type that can be indexed.  | 
            ||
| 438 | * Currently standard pages and mount pages can be indexed.  | 
            ||
| 439 | *  | 
            ||
| 440 | * @param array $record A page record  | 
            ||
| 441 | * @return bool TRUE if the page can be indexed according to its page type, FALSE otherwise  | 
            ||
| 442 | */  | 
            ||
| 443 | protected function isIndexablePageType(array $record)  | 
            ||
| 447 | |||
| 448 | /**  | 
            ||
| 449 | * Cleans an index from garbage entries.  | 
            ||
| 450 | *  | 
            ||
| 451 | * Was used to clean the index from expired documents/past endtime. Solr 4.8  | 
            ||
| 452 | * introduced DocExpirationUpdateProcessor to do that job by itself.  | 
            ||
| 453 | *  | 
            ||
| 454 | * The method remains as a dummy for possible later cleanups and to prevent  | 
            ||
| 455 | * things from breaking if others were using it.  | 
            ||
| 456 | *  | 
            ||
| 457 | * @deprecated since 6.0 will be removed in 7.0. deletion is done by DocExpirationUpdateProcessor  | 
            ||
| 458 | * @param Site $site The site to clean indexes on  | 
            ||
| 459 | * @param bool $commitAfterCleanUp Whether to commit right after the clean up, defaults to TRUE  | 
            ||
| 460 | * @return void  | 
            ||
| 461 | */  | 
            ||
| 462 | public function cleanIndex(Site $site, $commitAfterCleanUp = true)  | 
            ||
| 466 | }  | 
            ||
| 467 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.