Complex classes like Debug 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 Debug, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 35 | class Debug extends AbstractLogger  | 
            ||
| 36 | { | 
            ||
| 37 | /**  | 
            ||
| 38 | * variable to activate or not the debug  | 
            ||
| 39 | * @var boolean  | 
            ||
| 40 | */  | 
            ||
| 41 | private static $_bActivateDebug = false;  | 
            ||
| 42 | |||
| 43 | /**  | 
            ||
| 44 | * variable to activate or not the error  | 
            ||
| 45 | * @var boolean  | 
            ||
| 46 | */  | 
            ||
| 47 | private static $_bActivateError = false;  | 
            ||
| 48 | |||
| 49 | /**  | 
            ||
| 50 | * variable to activate or not the exception  | 
            ||
| 51 | * @var boolean  | 
            ||
| 52 | */  | 
            ||
| 53 | private static $_bActivateException = false;  | 
            ||
| 54 | |||
| 55 | /**  | 
            ||
| 56 | * variable to activate or not the debug  | 
            ||
| 57 | * @var boolean  | 
            ||
| 58 | */  | 
            ||
| 59 | private static $_sFileLog = null;  | 
            ||
| 60 | |||
| 61 | /**  | 
            ||
| 62 | * first or not activation  | 
            ||
| 63 | * @var boolean  | 
            ||
| 64 | */  | 
            ||
| 65 | private static $_bFirstActivation = true;  | 
            ||
| 66 | |||
| 67 | /**  | 
            ||
| 68 | * kind of report log  | 
            ||
| 69 | * @var string error_log|screen|all  | 
            ||
| 70 | */  | 
            ||
| 71 | private static $_sKindOfReportLog = 'error_log';  | 
            ||
| 72 | |||
| 73 | /**  | 
            ||
| 74 | * instance of logger  | 
            ||
| 75 | * @var \Venus\lib\Debug  | 
            ||
| 76 | */  | 
            ||
| 77 | private static $_oInstance;  | 
            ||
| 78 | |||
| 79 | /**  | 
            ||
| 80 | * Send back the isntance or create it  | 
            ||
| 81 | *  | 
            ||
| 82 | * @access public  | 
            ||
| 83 | */  | 
            ||
| 84 | public static function getInstance() : Debug  | 
            ||
| 90 | |||
| 91 | /**  | 
            ||
| 92 | * activate debug  | 
            ||
| 93 | *  | 
            ||
| 94 | * @access public  | 
            ||
| 95 | * @return void  | 
            ||
| 96 | */  | 
            ||
| 97 | public static function activateDebug()  | 
            ||
| 110 | |||
| 111 | /**  | 
            ||
| 112 | * activate debug  | 
            ||
| 113 | *  | 
            ||
| 114 | * @access public  | 
            ||
| 115 | * @return void  | 
            ||
| 116 | */  | 
            ||
| 117 | public static function deactivateDebug()  | 
            ||
| 121 | |||
| 122 | /**  | 
            ||
| 123 | * check if debug is activate or not  | 
            ||
| 124 | *  | 
            ||
| 125 | * @access public  | 
            ||
| 126 | * @return boolean  | 
            ||
| 127 | */  | 
            ||
| 128 | public static function isDebug() : bool  | 
            ||
| 132 | |||
| 133 | /**  | 
            ||
| 134 | * activate error reporting  | 
            ||
| 135 | *  | 
            ||
| 136 | * @access public  | 
            ||
| 137 | * @param int $iLevel level of error  | 
            ||
| 138 | * @return void  | 
            ||
| 139 | */  | 
            ||
| 140 | public static function activateError($iLevel)  | 
            ||
| 176 | |||
| 177 | /**  | 
            ||
| 178 | * activate error reporting  | 
            ||
| 179 | *  | 
            ||
| 180 | * @access public  | 
            ||
| 181 | * @return void  | 
            ||
| 182 | */  | 
            ||
| 183 | public static function deactivateError()  | 
            ||
| 187 | |||
| 188 | /**  | 
            ||
| 189 | * check if error reporting is activate or not  | 
            ||
| 190 | *  | 
            ||
| 191 | * @access public  | 
            ||
| 192 | * @return boolean  | 
            ||
| 193 | */  | 
            ||
| 194 | public static function isError() : bool  | 
            ||
| 198 | |||
| 199 | |||
| 200 | /**  | 
            ||
| 201 | * activate Exception  | 
            ||
| 202 | *  | 
            ||
| 203 | * @access public  | 
            ||
| 204 | * @param int $iLevel level of error  | 
            ||
| 205 | * @return void  | 
            ||
| 206 | */  | 
            ||
| 207 | public static function activateException(int $iLevel)  | 
            ||
| 224 | |||
| 225 | /**  | 
            ||
| 226 | * activate Exception  | 
            ||
| 227 | *  | 
            ||
| 228 | * @access public  | 
            ||
| 229 | * @return void  | 
            ||
| 230 | */  | 
            ||
| 231 | public static function deactivateException()  | 
            ||
| 235 | |||
| 236 | /**  | 
            ||
| 237 | * check if Exception is activate or not  | 
            ||
| 238 | *  | 
            ||
| 239 | * @access public  | 
            ||
| 240 | * @return boolean  | 
            ||
| 241 | */  | 
            ||
| 242 | public static function isException() : bool  | 
            ||
| 246 | |||
| 247 | /**  | 
            ||
| 248 | * set the kind of report Log  | 
            ||
| 249 | *  | 
            ||
| 250 | * @access public  | 
            ||
| 251 | * @param string $sKindOfReportLog  | 
            ||
| 252 | * @return void  | 
            ||
| 253 | */  | 
            ||
| 254 | public static function setKindOfReportLog(string $sKindOfReportLog)  | 
            ||
| 259 | |||
| 260 | /**  | 
            ||
| 261 | * get the kind of report Log  | 
            ||
| 262 | *  | 
            ||
| 263 | * @access public  | 
            ||
| 264 | * @return string  | 
            ||
| 265 | */  | 
            ||
| 266 | public static function getKindOfReportLog() : string  | 
            ||
| 270 | |||
| 271 | /**  | 
            ||
| 272 | * get the code by LogLevel adapt to the PSR-3  | 
            ||
| 273 | *  | 
            ||
| 274 | * @access public  | 
            ||
| 275 | * @param int $iCode  | 
            ||
| 276 | * @return string  | 
            ||
| 277 | */  | 
            ||
| 278 | public static function getTranslateErrorCode(int $iCode) : string  | 
            ||
| 287 | |||
| 288 | /**  | 
            ||
| 289 | * System is unusable.  | 
            ||
| 290 | *  | 
            ||
| 291 | * @param string $message  | 
            ||
| 292 | * @param array $context  | 
            ||
| 293 | * @return null  | 
            ||
| 294 | */  | 
            ||
| 295 | public function emergency($message, array $context = array())  | 
            ||
| 299 | |||
| 300 | /**  | 
            ||
| 301 | * Action must be taken immediately.  | 
            ||
| 302 | *  | 
            ||
| 303 | * Example: Entire website down, database unavailable, etc. This should  | 
            ||
| 304 | * trigger the SMS alerts and wake you up.  | 
            ||
| 305 | *  | 
            ||
| 306 | * @param string $message  | 
            ||
| 307 | * @param array $context  | 
            ||
| 308 | * @return null  | 
            ||
| 309 | */  | 
            ||
| 310 | public function alert($message, array $context = array())  | 
            ||
| 314 | |||
| 315 | /**  | 
            ||
| 316 | * Critical conditions.  | 
            ||
| 317 | *  | 
            ||
| 318 | * Example: Application component unavailable, unexpected exception.  | 
            ||
| 319 | *  | 
            ||
| 320 | * @param string $message  | 
            ||
| 321 | * @param array $context  | 
            ||
| 322 | * @return null  | 
            ||
| 323 | */  | 
            ||
| 324 | public function critical($message, array $context = array())  | 
            ||
| 328 | |||
| 329 | /**  | 
            ||
| 330 | * Runtime errors that do not require immediate action but should typically  | 
            ||
| 331 | * be logged and monitored.  | 
            ||
| 332 | *  | 
            ||
| 333 | * @param string $message  | 
            ||
| 334 | * @param array $context  | 
            ||
| 335 | * @return null  | 
            ||
| 336 | */  | 
            ||
| 337 | public function error($message, array $context = array())  | 
            ||
| 341 | |||
| 342 | /**  | 
            ||
| 343 | * Exceptional occurrences that are not errors.  | 
            ||
| 344 | *  | 
            ||
| 345 | * Example: Use of deprecated APIs, poor use of an API, undesirable things  | 
            ||
| 346 | * that are not necessarily wrong.  | 
            ||
| 347 | *  | 
            ||
| 348 | * @param string $message  | 
            ||
| 349 | * @param array $context  | 
            ||
| 350 | * @return null  | 
            ||
| 351 | */  | 
            ||
| 352 | public function warning($message, array $context = array())  | 
            ||
| 356 | |||
| 357 | /**  | 
            ||
| 358 | * Normal but significant events.  | 
            ||
| 359 | *  | 
            ||
| 360 | * @param string $message  | 
            ||
| 361 | * @param array $context  | 
            ||
| 362 | * @return null  | 
            ||
| 363 | */  | 
            ||
| 364 | public function notice($message, array $context = array())  | 
            ||
| 368 | |||
| 369 | /**  | 
            ||
| 370 | * Interesting events.  | 
            ||
| 371 | *  | 
            ||
| 372 | * Example: User logs in, SQL logs.  | 
            ||
| 373 | *  | 
            ||
| 374 | * @param string $message  | 
            ||
| 375 | * @param array $context  | 
            ||
| 376 | * @return null  | 
            ||
| 377 | */  | 
            ||
| 378 | public function info($message, array $context = array())  | 
            ||
| 382 | |||
| 383 | /**  | 
            ||
| 384 | * Detailed debug information.  | 
            ||
| 385 | *  | 
            ||
| 386 | * @param string $message  | 
            ||
| 387 | * @param array $context  | 
            ||
| 388 | * @return null  | 
            ||
| 389 | */  | 
            ||
| 390 | public function debug($message, array $context = array())  | 
            ||
| 394 | |||
| 395 | /**  | 
            ||
| 396 | * set the name of the called  | 
            ||
| 397 | *  | 
            ||
| 398 | * @access public  | 
            ||
| 399 | * @return void  | 
            ||
| 400 | */  | 
            ||
| 401 | private static function _setFileNameInErrorFile()  | 
            ||
| 418 | |||
| 419 | /**  | 
            ||
| 420 | * init the log file (error_log)  | 
            ||
| 421 | *  | 
            ||
| 422 | * @access private  | 
            ||
| 423 | * @return void  | 
            ||
| 424 | */  | 
            ||
| 425 | private static function _initLogFile()  | 
            ||
| 435 | |||
| 436 | /**  | 
            ||
| 437 | * constructor in private for the singleton  | 
            ||
| 438 | *  | 
            ||
| 439 | * @access private  | 
            ||
| 440 | * @return \Venus\lib\Debug  | 
            ||
| 441 | */  | 
            ||
| 442 |     private function __construct() {} | 
            ||
| 443 | |||
| 444 | /**  | 
            ||
| 445 | * not allowed to clone a object  | 
            ||
| 446 | *  | 
            ||
| 447 | * @access private  | 
            ||
| 448 | * @return \Venus\lib\Debug  | 
            ||
| 449 | */  | 
            ||
| 450 |     private function __clone() {} | 
            ||
| 451 | }  | 
            ||
| 452 | 
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.