| Conditions | 1 |
| Paths | 1 |
| Total Lines | 72 |
| Code Lines | 46 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | 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->paramsNames[static::ACTION_FIELD_QUESTION], |
||
| 24 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_FILE], |
||
| 25 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_PHRASE], |
||
| 26 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_PINGBACK], |
||
| 27 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_REGSENSE], |
||
| 28 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_NUMERIC], |
||
| 29 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_CALC], |
||
| 30 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_MIN_LEN], |
||
| 31 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_MAX_LEN], |
||
| 32 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][self::ACTION_FIELD_QUESTION] |
||
| 33 | ); |
||
| 34 | |||
| 35 | $this->paramsNames[static::ACTION_FIELD_GOOGLEKEY] = 'googlekey'; |
||
| 36 | $this->paramsNames[static::ACTION_FIELD_PROXY] = 'proxy'; |
||
| 37 | $this->paramsNames[static::ACTION_FIELD_PROXYTYPE] = 'proxytype'; |
||
| 38 | $this->paramsNames[static::ACTION_FIELD_PAGEURL] = 'pageurl'; |
||
| 39 | |||
| 40 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_METHOD][static::PARAM_SLUG_DEFAULT] = 'userrecaptcha'; |
||
| 41 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_GOOGLEKEY] = [ |
||
| 42 | static::PARAM_SLUG_REQUIRE => true, |
||
| 43 | static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
||
| 44 | ]; |
||
| 45 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_PROXY] = [ |
||
| 46 | static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
||
| 47 | ]; |
||
| 48 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_PROXYTYPE] = [ |
||
| 49 | static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
||
| 50 | ]; |
||
| 51 | $this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_PAGEURL] = [ |
||
| 52 | static::PARAM_SLUG_REQUIRE => true, |
||
| 53 | static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
||
| 54 | ]; |
||
| 55 | |||
| 56 | $this->wiki->setText(['service', 'name'], [ |
||
| 57 | 'ru' => 'RuCaptcha ReCaptcha v2 без браузера', |
||
| 58 | ]); |
||
| 59 | $this->wiki->setText(['recognize', 'price'], [ |
||
| 60 | 'ru' => '1000 решений стоят 160 рублей.', |
||
| 61 | ]); |
||
| 62 | $this->wiki->setText(['recognize', 'desc'], [ |
||
| 63 | 'ru' => 'Данный способ позволяет пройти рекапчу без эмуляции браузера и отправки нам картинок, так же этот способ даёт 100% прохождение капчи. |
||
| 64 | |||
| 65 | Где какие данные брать и куда вставлять? |
||
| 66 | Посмотрите HTML-код страницы, где Вы встретили капчу: |
||
| 67 | |||
| 68 | 1. найдите параметр |
||
| 69 | data-sitekey= |
||
| 70 | Это ключ сайта, он постоянен и уникален для каждого сайта (если администратор сайта не поменяет его вручную) |
||
| 71 | |||
| 72 | 2.найдите форму для текста |
||
| 73 | ```<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none; "></textarea>``` |
||
| 74 | Сюда вам нужно будет вставить ответ от нас.', |
||
| 75 | ]); |
||
| 76 | $this->wiki->setText(['recognize','data'], [ |
||
| 77 | static::ACTION_FIELD_GOOGLEKEY => '54as5c6a5s4ca4s56a4sc56a', |
||
| 78 | static::ACTION_FIELD_PAGEURL => 'http://site.com/recaptcha-ex', |
||
| 79 | ]); |
||
| 80 | $this->wiki->setText(['recognize','file'], false); |
||
|
|
|||
| 81 | } |
||
| 82 | |||
| 88 |
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: