forked from php-telegram-bot/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Other Changes pt. 2: Added Factory and NotImplemented class
- Loading branch information
Showing
4 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Longman\TelegramBot\Entities\MessageOrigin; | ||
|
||
use Longman\TelegramBot\Entities\Entity; | ||
|
||
class Factory extends \Longman\TelegramBot\Entities\Factory | ||
{ | ||
public static function make(array $data, string $bot_username): Entity | ||
{ | ||
$type = [ | ||
'user' => MessageOriginUser::class, | ||
'hidden_user' => MessageOriginHiddenUser::class, | ||
'chat' => MessageOriginChat::class, | ||
'channel' => MessageOriginChannel::class, | ||
]; | ||
|
||
if (!isset($type[$data['type'] ?? ''])) { | ||
return new MessageOriginNotImplemented($data, $bot_username); | ||
} | ||
|
||
$class = $type[$data['type']]; | ||
return new $class($data, $bot_username); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Entities/MessageOrigin/MessageOriginNotImplemented.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Longman\TelegramBot\Entities\MessageOrigin; | ||
|
||
use Longman\TelegramBot\Entities\Entity; | ||
|
||
/** | ||
* @method string getType() Type of the message origin | ||
* @method int getDate() Date the message was sent originally in Unix time | ||
*/ | ||
class MessageOriginNotImplemented extends Entity implements MessageOrigin | ||
{ | ||
|
||
} |