| Conditions | 1 |
| Paths | 1 |
| Total Lines | 66 |
| Code Lines | 43 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 2 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 10 | public function init() |
||
| 11 | { |
||
| 12 | parent::init(); |
||
| 13 | |||
| 14 | unset( |
||
| 15 | $this->paramsNames[static::ACTION_FIELD_FILE], |
||
| 16 | $this->paramsNames[static::ACTION_FIELD_PHRASE], |
||
| 17 | $this->paramsNames[static::ACTION_FIELD_PINGBACK], |
||
| 18 | $this->paramsNames[static::ACTION_FIELD_REGSENSE], |
||
| 19 | $this->paramsNames[static::ACTION_FIELD_NUMERIC], |
||
| 20 | $this->paramsNames[static::ACTION_FIELD_CALC], |
||
| 21 | $this->paramsNames[static::ACTION_FIELD_MIN_LEN], |
||
| 22 | $this->paramsNames[static::ACTION_FIELD_MAX_LEN], |
||
| 23 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS][self::ACTION_FIELD_FILE], |
||
| 24 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS][self::ACTION_FIELD_PHRASE], |
||
| 25 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS][self::ACTION_FIELD_PINGBACK], |
||
| 26 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS][self::ACTION_FIELD_REGSENSE], |
||
| 27 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS][self::ACTION_FIELD_NUMERIC], |
||
| 28 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS][self::ACTION_FIELD_CALC], |
||
| 29 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS][self::ACTION_FIELD_MIN_LEN], |
||
| 30 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS][self::ACTION_FIELD_MAX_LEN] |
||
| 31 | ); |
||
| 32 | |||
| 33 | $this->paramsNames[static::ACTION_FIELD_PAGEURL] = 'websiteURL'; |
||
| 34 | $this->paramsNames[static::ACTION_FIELD_GOOGLEKEY] = 'websiteKey'; |
||
| 35 | $this->paramsNames[static::ACTION_FIELD_GOOGLETOKEN] = 'websiteSToken'; |
||
| 36 | |||
| 37 | $task = &$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_TASK][static::ACTION_FIELDS]; |
||
| 38 | $task[static::ACTION_FIELD_METHOD][static::PARAM_SLUG_DEFAULT] = 'NoCaptchaTask'; |
||
| 39 | $task[static::ACTION_FIELD_PAGEURL] = [ |
||
| 40 | static::PARAM_SLUG_REQUIRE => true, |
||
| 41 | static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
||
| 42 | ]; |
||
| 43 | $task[static::ACTION_FIELD_GOOGLEKEY] = [ |
||
| 44 | static::PARAM_SLUG_REQUIRE => true, |
||
| 45 | static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
||
| 46 | ]; |
||
| 47 | $task[static::ACTION_FIELD_GOOGLETOKEN] = [ |
||
| 48 | static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
||
| 49 | ]; |
||
| 50 | |||
| 51 | $this->decodeSettings[static::DECODE_ACTION][static::DECODE_ACTION_GET][static::DECODE_PARAMS][static::DECODE_PARAM_CODE][static::DECODE_PARAM_SETTING_MARKER] = 'solution.gRecaptchaResponse'; |
||
| 52 | |||
| 53 | $this->wiki->setText(['service', 'name'], [ |
||
| 54 | 'ru' => 'AntiCaptcha ReCaptcha v2 без браузера', |
||
| 55 | ]); |
||
| 56 | $this->wiki->setText(['recognize', 'price'], [ |
||
| 57 | 'ru' => 'Стоимость Рекапчи: от 2 USD за 1000 решений.', |
||
| 58 | ]); |
||
| 59 | $this->wiki->setText(['recognize', 'desc'], [ |
||
| 60 | 'ru' => 'Вам не нужно эмулировать браузер и запускать яваскрипты. |
||
| 61 | |||
| 62 | Вы присылаете нам значение "sitekey". |
||
| 63 | |||
| 64 | Мы передаем вам "g-recaptcha-response" и вы просто делаете сабмит формы с этим параметром. |
||
| 65 | |||
| 66 | Объект содержит данные о задаче на решение рекапчи гугла в браузере на компьютере работника. |
||
| 67 | Такая задача будет выполняться нашим сервисом с использованием наших собственных прокси-серверов и/или с IP адресов работников. |
||
| 68 | Стоимость решения такой задачи на 10% выше, чем у AnticaptchaReCaptcha, так как на нас ложится проблема обхода лимитов на количество решений рекапч с 1 IP адреса.', |
||
| 69 | ]); |
||
| 70 | $this->wiki->setText(['recognize', 'data'], [ |
||
| 71 | static::ACTION_FIELD_GOOGLEKEY => '54as5c6a5s4ca4s56a4sc56a', |
||
| 72 | static::ACTION_FIELD_PAGEURL => 'http://site.com/recaptcha-ex', |
||
| 73 | ]); |
||
| 74 | $this->wiki->setText(['recognize', 'file'], false); |
||
|
|
|||
| 75 | } |
||
| 76 | |||
| 82 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: