Complex classes like GateKeeper 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 GateKeeper, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 8 | class GateKeeper  | 
            ||
| 9 | { | 
            ||
| 10 | /**  | 
            ||
| 11 | * [plugin_file_path] => [plugin_name]|[plugin_version]|[plugin_url]  | 
            ||
| 12 | */  | 
            ||
| 13 | const DEPENDENCIES = [  | 
            ||
| 14 | 'meta-box/meta-box.php' => 'Meta Box|4.11|https://wordpress.org/plugins/meta-box/',  | 
            ||
| 15 | ];  | 
            ||
| 16 | |||
| 17 | public $errors = [];  | 
            ||
| 18 | |||
| 19 | /**  | 
            ||
| 20 | * @var Notice  | 
            ||
| 21 | */  | 
            ||
| 22 | protected $notice;  | 
            ||
| 23 | |||
| 24 | /**  | 
            ||
| 25 | * @var string  | 
            ||
| 26 | */  | 
            ||
| 27 | protected $plugin;  | 
            ||
| 28 | |||
| 29 | public function __construct( $plugin )  | 
            ||
| 34 | |||
| 35 | public function init()  | 
            ||
| 44 | |||
| 45 | /**  | 
            ||
| 46 | * @return void  | 
            ||
| 47 | */  | 
            ||
| 48 | public function activatePlugin()  | 
            ||
| 62 | |||
| 63 | /**  | 
            ||
| 64 | * @return void  | 
            ||
| 65 | */  | 
            ||
| 66 | public function ajaxActivatePluginLink()  | 
            ||
| 84 | |||
| 85 | /**  | 
            ||
| 86 | * @return bool  | 
            ||
| 87 | */  | 
            ||
| 88 | public function hasDependency( $plugin )  | 
            ||
| 95 | |||
| 96 | /**  | 
            ||
| 97 | * @return bool  | 
            ||
| 98 | */  | 
            ||
| 99 | public function hasPendingDependencies()  | 
            ||
| 108 | |||
| 109 | /**  | 
            ||
| 110 | * @return bool  | 
            ||
| 111 | */  | 
            ||
| 112 | public function isPluginActive( $plugin )  | 
            ||
| 118 | |||
| 119 | /**  | 
            ||
| 120 | * @return bool  | 
            ||
| 121 | */  | 
            ||
| 122 | public function isPluginDependency( $plugin )  | 
            ||
| 126 | |||
| 127 | /**  | 
            ||
| 128 | * @return bool  | 
            ||
| 129 | */  | 
            ||
| 130 | public function isPluginInstalled( $plugin )  | 
            ||
| 136 | |||
| 137 | /**  | 
            ||
| 138 | * @return bool  | 
            ||
| 139 | */  | 
            ||
| 140 | public function isPluginValid( $plugin )  | 
            ||
| 144 | |||
| 145 | /**  | 
            ||
| 146 | * @return bool  | 
            ||
| 147 | */  | 
            ||
| 148 | public function isPluginVersionValid( $plugin )  | 
            ||
| 162 | |||
| 163 | /**  | 
            ||
| 164 | * @return void  | 
            ||
| 165 | */  | 
            ||
| 166 | public function printNotices()  | 
            ||
| 172 | |||
| 173 | /**  | 
            ||
| 174 | * @return void|null  | 
            ||
| 175 | */  | 
            ||
| 176 | public function setDependencyNotice()  | 
            ||
| 188 | |||
| 189 | /**  | 
            ||
| 190 | * @param string $plugin  | 
            ||
| 191 | * @param string $error  | 
            ||
| 192 | * @param bool $isValid  | 
            ||
| 193 | * @return bool  | 
            ||
| 194 | */  | 
            ||
| 195 | protected function catchError( $plugin, $error, $isValid )  | 
            ||
| 207 | |||
| 208 | /**  | 
            ||
| 209 | * @return array  | 
            ||
| 210 | */  | 
            ||
| 211 | protected function getAllPlugins()  | 
            ||
| 216 | |||
| 217 | /**  | 
            ||
| 218 | * @return string  | 
            ||
| 219 | */  | 
            ||
| 220 | protected function getDependencyActions()  | 
            ||
| 236 | |||
| 237 | /**  | 
            ||
| 238 | * @return string  | 
            ||
| 239 | */  | 
            ||
| 240 | protected function getDependencyLinks()  | 
            ||
| 246 | |||
| 247 | /**  | 
            ||
| 248 | * @return array  | 
            ||
| 249 | */  | 
            ||
| 250 | protected function getMustUsePlugins()  | 
            ||
| 261 | |||
| 262 | /**  | 
            ||
| 263 | * @return array|false  | 
            ||
| 264 | */  | 
            ||
| 265 | protected function getPlugin( $plugin )  | 
            ||
| 272 | |||
| 273 | /**  | 
            ||
| 274 | * @return array|string  | 
            ||
| 275 | */  | 
            ||
| 276 | protected function getPluginData( $plugin, $data, $key = null )  | 
            ||
| 292 | |||
| 293 | /**  | 
            ||
| 294 | * @return array|string  | 
            ||
| 295 | */  | 
            ||
| 296 | protected function getPluginInformation( $plugin, $key = null )  | 
            ||
| 300 | |||
| 301 | /**  | 
            ||
| 302 | * @return string  | 
            ||
| 303 | */  | 
            ||
| 304 | protected function getPluginLink( $plugin )  | 
            ||
| 318 | |||
| 319 | /**  | 
            ||
| 320 | * @return array|string  | 
            ||
| 321 | */  | 
            ||
| 322 | protected function getPluginRequirements( $plugin, $key = null )  | 
            ||
| 330 | |||
| 331 | /**  | 
            ||
| 332 | * @return string  | 
            ||
| 333 | */  | 
            ||
| 334 | protected function getPluginSlug( $plugin )  | 
            ||
| 338 | }  | 
            ||
| 339 | 
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.