Complex classes like DeCaptchaAbstract 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 DeCaptchaAbstract, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 10 | abstract class DeCaptchaAbstract implements DeCaptchaInterface  | 
            ||
| 11 | { | 
            ||
| 12 | const RESPONSE_TYPE_STRING = 1;  | 
            ||
| 13 | const RESPONSE_TYPE_JSON = 2;  | 
            ||
| 14 | |||
| 15 | const ACTION_FIELDS = 1;  | 
            ||
| 16 | const ACTION_URI = 2;  | 
            ||
| 17 | const ACTION_METHOD = 3;  | 
            ||
| 18 | const ACTION_JSON = 4;  | 
            ||
| 19 | |||
| 20 | const ACTION_METHOD_POST = 1;  | 
            ||
| 21 | const ACTION_METHOD_GET = 2;  | 
            ||
| 22 | |||
| 23 | const DECODE_FORMAT = 1;  | 
            ||
| 24 | const DECODE_ACTION = 2;  | 
            ||
| 25 | const DECODE_SEPARATOR = 3;  | 
            ||
| 26 | const DECODE_PARAMS = 4;  | 
            ||
| 27 | const DECODE_PARAM_SETTING_MARKER = 5;  | 
            ||
| 28 | |||
| 29 | const PARAM_FIELD_TYPE_STRING = 1;  | 
            ||
| 30 | const PARAM_FIELD_TYPE_INTEGER = 2;  | 
            ||
| 31 | const PARAM_FIELD_TYPE_MIX = 3;  | 
            ||
| 32 | const PARAM_FIELD_TYPE_OBJECT = 4;  | 
            ||
| 33 | const PARAM_FIELD_TYPE_BOOLEAN = 5;  | 
            ||
| 34 | |||
| 35 | const PARAM_SLUG_DEFAULT = 1;  | 
            ||
| 36 | const PARAM_SLUG_TYPE = 2;  | 
            ||
| 37 | const PARAM_SLUG_REQUIRE = 3;  | 
            ||
| 38 | const PARAM_SLUG_SPEC = 4;  | 
            ||
| 39 | const PARAM_SLUG_VARIABLE = 5;  | 
            ||
| 40 | const PARAM_SLUG_CODING = 6;  | 
            ||
| 41 | |||
| 42 | const PARAM_SLUG_CODING_BASE64 = 1;  | 
            ||
| 43 | |||
| 44 | const PARAM_SPEC_API_KEY = -1;  | 
            ||
| 45 | const PARAM_SPEC_FILE = -2;  | 
            ||
| 46 | const PARAM_SPEC_CAPTCHA = -3;  | 
            ||
| 47 | const PARAM_SPEC_CODE = -4;  | 
            ||
| 48 | |||
| 49 | /**  | 
            ||
| 50 | * Сервис на который будем загружать капчу.  | 
            ||
| 51 | *  | 
            ||
| 52 | * @var string  | 
            ||
| 53 | */  | 
            ||
| 54 | protected $host;  | 
            ||
| 55 | protected $scheme = 'http';  | 
            ||
| 56 | protected $errorLang = DeCaptchaErrors::LANG_EN;  | 
            ||
| 57 | protected $lastRunTime = null;  | 
            ||
| 58 | /** @var DeCaptchaErrors */  | 
            ||
| 59 | protected $errorObject;  | 
            ||
| 60 | protected $causeAnError = false;  | 
            ||
| 61 | |||
| 62 | protected $limit = [];  | 
            ||
| 63 | protected $paramsSpec = [];  | 
            ||
| 64 | protected $params = [];  | 
            ||
| 65 | protected $limitSettings = [];  | 
            ||
| 66 | protected $decodeSettings = [];  | 
            ||
| 67 | protected $actions = [];  | 
            ||
| 68 | protected $paramsNames = [];  | 
            ||
| 69 | |||
| 70 | protected function resetLimits()  | 
            ||
| 76 | |||
| 77 | /**  | 
            ||
| 78 | * @param $action  | 
            ||
| 79 | *  | 
            ||
| 80 | * @return bool  | 
            ||
| 81 | */  | 
            ||
| 82 | protected function limitHasNotYetEnded($action)  | 
            ||
| 86 | |||
| 87 | /**  | 
            ||
| 88 | * @param $action  | 
            ||
| 89 | * @param $data  | 
            ||
| 90 | *  | 
            ||
| 91 | * @throws DeCaptchaErrors  | 
            ||
| 92 | 3 | *  | 
            |
| 93 | * @return array  | 
            ||
| 94 | 3 | */  | 
            |
| 95 | 1 | protected function decodeResponse($action, $data)  | 
            |
| 135 | |||
| 136 | 4 | /**  | 
            |
| 137 | 4 | * @param $errorLang  | 
            |
| 138 | */  | 
            ||
| 139 | public function setErrorLang($errorLang)  | 
            ||
| 143 | |||
| 144 | 2 | /**  | 
            |
| 145 | 2 | * Узнаём путь до файла  | 
            |
| 146 | * Если передана ссылка, то скачиваем и кладём во временную директорию.  | 
            ||
| 147 | *  | 
            ||
| 148 | * @param string $fileName  | 
            ||
| 149 | *  | 
            ||
| 150 | * @throws Exception  | 
            ||
| 151 | *  | 
            ||
| 152 | 1 | * @return string  | 
            |
| 153 | 1 | */  | 
            |
| 154 | protected function getFilePath($fileName)  | 
            ||
| 172 | 1 | ||
| 173 | /**  | 
            ||
| 174 | 1 | * @param $action  | 
            |
| 175 | *  | 
            ||
| 176 | * @return string  | 
            ||
| 177 | */  | 
            ||
| 178 | protected function getActionUrl($action)  | 
            ||
| 182 | |||
| 183 | /**  | 
            ||
| 184 | * @return string  | 
            ||
| 185 | 1 | */  | 
            |
| 186 | 1 | protected function getBaseUrl()  | 
            |
| 190 | 1 | ||
| 191 | 1 | /**  | 
            |
| 192 | 1 | * @param $params  | 
            |
| 193 | */  | 
            ||
| 194 | public function setParams($params)  | 
            ||
| 202 | |||
| 203 | /**  | 
            ||
| 204 | * @param $param  | 
            ||
| 205 | * @param $value  | 
            ||
| 206 | */  | 
            ||
| 207 | public function setParam($param, $value)  | 
            ||
| 211 | |||
| 212 | /**  | 
            ||
| 213 | * @param $param  | 
            ||
| 214 | * @param $coding  | 
            ||
| 215 | *  | 
            ||
| 216 | * @return \CURLFile|mixed|null|string  | 
            ||
| 217 | */  | 
            ||
| 218 | public function getParamSpec($param, $coding = null)  | 
            ||
| 241 | |||
| 242 | /**  | 
            ||
| 243 | * @param $action  | 
            ||
| 244 | * @param $field  | 
            ||
| 245 | *  | 
            ||
| 246 | * @throws DeCaptchaErrors  | 
            ||
| 247 | *  | 
            ||
| 248 | * @return array  | 
            ||
| 249 | */  | 
            ||
| 250 | protected function getParams($action, $field = null)  | 
            ||
| 301 | |||
| 302 | /**  | 
            ||
| 303 | * @param string $action  | 
            ||
| 304 | *  | 
            ||
| 305 | * @return string  | 
            ||
| 306 | */  | 
            ||
| 307 | protected function getResponse($action)  | 
            ||
| 316 | |||
| 317 | /**  | 
            ||
| 318 | * Задержка выполнения.  | 
            ||
| 319 | *  | 
            ||
| 320 | * @param int $delay Количество секунд  | 
            ||
| 321 | * @param \Closure|null $callback  | 
            ||
| 322 | *  | 
            ||
| 323 | * @return mixed  | 
            ||
| 324 | */  | 
            ||
| 325 | protected function executionDelayed($delay = 0, $callback = null)  | 
            ||
| 336 | |||
| 337 | /**  | 
            ||
| 338 | * @param string $url  | 
            ||
| 339 | * @param array $data  | 
            ||
| 340 | * @param bool $isPost  | 
            ||
| 341 | * @param bool $isJson  | 
            ||
| 342 | *  | 
            ||
| 343 | * @throws DeCaptchaErrors  | 
            ||
| 344 | *  | 
            ||
| 345 | * @return string  | 
            ||
| 346 | */  | 
            ||
| 347 | protected function getCurlResponse($url, $data, $isPost = true, $isJson = false)  | 
            ||
| 386 | |||
| 387 | abstract public function getCode();  | 
            ||
| 388 | |||
| 389 | abstract public function getError();  | 
            ||
| 390 | }  | 
            ||
| 391 |