Skip to content

Commit

Permalink
Merge pull request #436 from NumairAwan/patch-1
Browse files Browse the repository at this point in the history
Update ForceReply.php
  • Loading branch information
BoShurik authored Aug 9, 2023
2 parents 65f9b4a + 5382dbd commit c8edc22
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ All Notable changes to `PHP Telegram Bot Api` will be documented in this file
- Add `\TelegramBot\Api\BotApi::getChatMemberCount` method
- Add `\TelegramBot\Api\BotApi::banChatMember` method
- Add `$messageId` to `\TelegramBot\Api\BotApi::unpinChatMessage`
- Add `\TelegramBot\Api\Types\ForceReply::$inputFieldPlaceholder` property

### Deprecated
- Deprecate using `thumb*` methods in `\TelegramBot\Api\BotApi`
Expand Down
29 changes: 28 additions & 1 deletion src/Types/ForceReply.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ForceReply extends BaseType
*/
protected static $map = [
'force_reply' => true,
'input_field_placeholder' => true,
'selective' => true
];

Expand All @@ -38,6 +39,13 @@ class ForceReply extends BaseType
*/
protected $forceReply;

/**
* The placeholder to be shown in the input field when the reply is active; 1-64 characters
*
* @var string|null
*/
protected $inputFieldPlaceholder;

/**
* Optional. Use this parameter if you want to show the keyboard to specific users only.
* Targets:
Expand All @@ -51,11 +59,13 @@ class ForceReply extends BaseType
/**
* @param bool $forceReply
* @param bool|null $selective
* @param string|null $inputFieldPlaceholder
*/
public function __construct($forceReply = true, $selective = null)
public function __construct($forceReply = true, $selective = null, $inputFieldPlaceholder = null)
{
$this->forceReply = $forceReply;
$this->selective = $selective;
$this->inputFieldPlaceholder = $inputFieldPlaceholder;
}

/**
Expand Down Expand Up @@ -91,4 +101,21 @@ public function setSelective($selective)
{
$this->selective = $selective;
}

/**
* @param string|null $inputFieldPlaceholder
* @return void
*/
public function setInputFieldPlaceholder($inputFieldPlaceholder)
{
$this->inputFieldPlaceholder = $inputFieldPlaceholder;
}

/**
* @return string|null
*/
public function getInputFieldPlaceholder()
{
return $this->inputFieldPlaceholder;
}
}
7 changes: 7 additions & 0 deletions tests/Types/ForceReplyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static function getFullResponse()
{
return [
'force_reply' => true,
'input_field_placeholder' => 'input_field_placeholder',
'selective' => true
];
}
Expand All @@ -35,6 +36,7 @@ protected function assertMinItem($item)
{
$this->assertEquals(true, $item->isForceReply());
$this->assertEquals(null, $item->isSelective());
$this->assertEquals(null, $item->getInputFieldPlaceholder());
}

/**
Expand All @@ -45,6 +47,7 @@ protected function assertFullItem($item)
{
$this->assertEquals(true, $item->isForceReply());
$this->assertEquals(true, $item->isSelective());
$this->assertEquals('input_field_placeholder', $item->getInputFieldPlaceholder());
}

public function testConstructor()
Expand All @@ -53,6 +56,7 @@ public function testConstructor()

$this->assertEquals(true, $item->isForceReply());
$this->assertEquals(null, $item->isSelective());
$this->assertEquals(null, $item->getInputFieldPlaceholder());
}

public function testConstructor2()
Expand All @@ -61,6 +65,7 @@ public function testConstructor2()

$this->assertEquals(true, $item->isForceReply());
$this->assertEquals(true, $item->isSelective());
$this->assertEquals(null, $item->getInputFieldPlaceholder());
}

public function testConstructor3()
Expand All @@ -69,6 +74,7 @@ public function testConstructor3()

$this->assertEquals(false, $item->isForceReply());
$this->assertEquals(true, $item->isSelective());
$this->assertEquals(null, $item->getInputFieldPlaceholder());
}

public function testConstructor4()
Expand All @@ -77,6 +83,7 @@ public function testConstructor4()

$this->assertEquals(true, $item->isForceReply());
$this->assertEquals(null, $item->isSelective());
$this->assertEquals(null, $item->getInputFieldPlaceholder());
}

public function testSetforceReply()
Expand Down

0 comments on commit c8edc22

Please sign in to comment.