Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ForceReply.php #436

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading