Commit 0b9e5172 authored by Armando Lüscher's avatar Armando Lüscher

When getting update content, get the Entity object instead of an array.

Some tiny code fixes.
parent 5a62e3b7
......@@ -45,7 +45,7 @@ class GenericCommand extends SystemCommand
//$chat_id = $message->getChat()->getId();
//$user_id = $message->getFrom()->getId();
//$command = $message->getCommand();
//#text = trim($message->getText(true));
//$text = trim($message->getText(true));
return parent::execute();
}
......
......@@ -13,7 +13,6 @@ namespace Longman\TelegramBot\Entities;
use Exception;
use Longman\TelegramBot\Entities\InlineQuery\InlineEntity;
use Longman\TelegramBot\TelegramLog;
use ReflectionObject;
/**
* Class Entity
......@@ -132,7 +131,7 @@ abstract class Entity
public function __call($method, $args)
{
//Convert method to snake_case (which is the name of the property)
$property_name = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', substr($method, 3))), '_');
$property_name = strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', substr($method, 3)), '_'));
$action = substr($method, 0, 3);
if ($action === 'get') {
......@@ -224,7 +223,7 @@ abstract class Entity
}
//Try with the username first...
$name = $this->getProperty('username');
$name = $this->getProperty('username');
$is_username = $name !== null;
if ($name === null) {
......
......@@ -78,7 +78,10 @@ class Update extends Entity
public function getUpdateContent()
{
if ($update_type = $this->getUpdateType()) {
return $this->getProperty($update_type);
// Instead of just getting the property as an array,
// use the __call method to get the correct Entity object.
$method = 'get' . str_replace('_', '', ucwords($update_type, '_'));
return $this->$method();
}
return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment