Complex classes like Helper 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 Helper, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 6 | class Helper  | 
            ||
| 7 | { | 
            ||
| 8 | protected static $methods = array();  | 
            ||
| 9 | |||
| 10 | 2 | public static function addMethod($ruleName, $callback)  | 
            |
| 20 | |||
| 21 | 1 | public static function methodExists($name)  | 
            |
| 25 | |||
| 26 | 2 | public static function __callStatic($name, $arguments)  | 
            |
| 33 | |||
| 34 | 1 | public static function callback($value, $callback, $context = array())  | 
            |
| 42 | |||
| 43 | 1 | public static function required($value)  | 
            |
| 47 | |||
| 48 | 2 | public static function truthy($value)  | 
            |
| 52 | |||
| 53 | 1 | public static function falsy($value)  | 
            |
| 57 | |||
| 58 | 1 | public static function number($value)  | 
            |
| 62 | |||
| 63 | 1 | public static function integer($value)  | 
            |
| 67 | |||
| 68 | 1 | public static function lessThan($value, $max)  | 
            |
| 78 | |||
| 79 | 1 | public static function greaterThan($value, $min)  | 
            |
| 89 | |||
| 90 | 1 | public static function between($value, $min, $max)  | 
            |
| 101 | |||
| 102 | 2 | public static function exactly($value, $otherValue)  | 
            |
| 106 | |||
| 107 | 1 | public static function not($value, $otherValue)  | 
            |
| 111 | |||
| 112 | 1 | public static function alpha($value)  | 
            |
| 118 | |||
| 119 | 1 | public static function alphanumeric($value)  | 
            |
| 125 | |||
| 126 | 1 | public static function alphanumhyphen($value)  | 
            |
| 132 | |||
| 133 | 1 | public static function minLength($value, $min)  | 
            |
| 143 | |||
| 144 | 1 | public static function maxLength($value, $max)  | 
            |
| 154 | |||
| 155 | 1 | public static function length($value, $min, $max)  | 
            |
| 166 | |||
| 167 | 1 | public static function setMinSize($value, $min)  | 
            |
| 177 | |||
| 178 | 1 | public static function setMaxSize($value, $max)  | 
            |
| 188 | |||
| 189 | 1 | public static function setSize($value, $min, $max)  | 
            |
| 200 | |||
| 201 | 1 | public static function inList($value, $values)  | 
            |
| 211 | |||
| 212 | 1 | public static function notInList($value, $values)  | 
            |
| 222 | |||
| 223 | 1 | public static function regex($value, $pattern)  | 
            |
| 233 | |||
| 234 | 1 | public static function notRegex($value, $pattern)  | 
            |
| 244 | |||
| 245 | 2 | public static function equalTo($value, $otherElementOrValue, $context = null)  | 
            |
| 253 | |||
| 254 | 1 | public static function notEqualTo($value, $otherElementOrValue, $context = null)  | 
            |
| 262 | 1 | ||
| 263 | public static function date($value, $format = 'Y-m-d')  | 
            ||
| 273 | 1 | ||
| 274 | public static function dateTime($value, $format = 'Y-m-d H:i:s')  | 
            ||
| 284 | 1 | ||
| 285 | public static function time($value, $format = 'H:i:s')  | 
            ||
| 295 | |||
| 296 | 1 | public static function website($value)  | 
            |
| 302 | |||
| 303 | public static function url($value)  | 
            ||
| 309 | |||
| 310 | 1 | /**  | 
            |
| 311 | * Test if a variable is a valid IP address  | 
            ||
| 312 | 1 | *  | 
            |
| 313 | * @param string $value  | 
            ||
| 314 | *  | 
            ||
| 315 | 1 | * @return bool  | 
            |
| 316 | */  | 
            ||
| 317 | 1 | public static function ipAddress($value)  | 
            |
| 323 | |||
| 324 | public static function email($value)  | 
            ||
| 330 | 1 | ||
| 331 | /**  | 
            ||
| 332 | 1 | * Test if a variable is a full name  | 
            |
| 333 | * Criterias: at least 6 characters, 2 words  | 
            ||
| 334 | 1 | *  | 
            |
| 335 | * @param mixed $value  | 
            ||
| 336 | *  | 
            ||
| 337 | * @return bool  | 
            ||
| 338 | */  | 
            ||
| 339 | public static function fullName($value)  | 
            ||
| 345 | |||
| 346 | 1 | /**  | 
            |
| 347 | * Test if the domain of an email address is available  | 
            ||
| 348 | 1 | *  | 
            |
| 349 | * @param string $value  | 
            ||
| 350 | *  | 
            ||
| 351 | * @return bool  | 
            ||
| 352 | */  | 
            ||
| 353 | public static function emailDomain($value)  | 
            ||
| 359 | }  | 
            ||
| 360 |