Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 14 | View Code Duplication | class ReplyKeyboardRemove extends BaseType |
|
| 15 | { |
||
| 16 | /** |
||
| 17 | * {@inheritdoc} |
||
| 18 | * |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | static protected $requiredParams = ['remove_keyboard']; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * {@inheritdoc} |
||
| 25 | * |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | static protected $map = [ |
||
| 29 | 'remove_keyboard' => true, |
||
| 30 | 'selective' => true |
||
| 31 | ]; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; |
||
| 35 | * if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup) |
||
| 36 | * |
||
| 37 | * @var bool |
||
| 38 | */ |
||
| 39 | protected $remove_keyboard; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Optional. Use this parameter if you want to remove the keyboard for specific users only. |
||
| 43 | * Targets: |
||
| 44 | * 1) users that are @mentioned in the text of the Message object; |
||
| 45 | * 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message. |
||
| 46 | * |
||
| 47 | * @var bool |
||
| 48 | */ |
||
| 49 | protected $selective; |
||
| 50 | |||
| 51 | public function __construct($remove_keyboard = true, $selective = false) |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return bool |
||
| 59 | */ |
||
| 60 | public function getRemoveKeyboard() |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @param bool $remove_keyboard |
||
| 67 | */ |
||
| 68 | public function setRemoveKeyboard($remove_keyboard) |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @return bool |
||
| 75 | */ |
||
| 76 | public function getSelective() |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @param bool $selective |
||
| 83 | */ |
||
| 84 | public function setSelective($selective) |
||
| 88 | } |
||
| 89 |