Commit f30ef525 authored by MBoretto's avatar MBoretto

updating chat entity

parent 8d3d8f13
...@@ -24,20 +24,17 @@ class Chat extends Entity ...@@ -24,20 +24,17 @@ class Chat extends Entity
public function __construct(array $data) public function __construct(array $data)
{ {
$this->id = isset($data['id']) ? $data['id'] : null; $this->id = isset($data['id']) ? $data['id'] : null;
if (empty($this->id)) { if (empty($this->id)) {
throw new TelegramException('id is empty!'); throw new TelegramException('id is empty!');
} }
//$this->type = isset($data['type']) ? $data['type'] : null;
if (isset($data['type'])) { if (isset($data['type'])) {
$this->type = $data['type']; $this->type = $data['type'];
} else { } else {
if ($this->isPrivateChat()) { if ($this->id > 0) {
$this->type = 'private'; $this->type = 'private';
} elseif ($this->isGroupChat()) { } elseif ($this->id < 0) {
$this->type = 'group'; $this->type = 'group';
} else { } else {
$this->type = null; $this->type = null;
...@@ -54,36 +51,32 @@ class Chat extends Entity ...@@ -54,36 +51,32 @@ class Chat extends Entity
{ {
if ($this->type == 'group' || $this->id < 0) { if ($this->type == 'group' || $this->id < 0) {
return true; return true;
} else {
return false;
} }
return false;
} }
public function isPrivateChat() public function isPrivateChat()
{ {
if ($this->type == 'private' || $this->id > 0) { if ($this->type == 'private') {
return true; return true;
} else {
return false;
} }
return false;
} }
public function isSuperGroup() public function isSuperGroup()
{ {
if ($this->type == 'supergroup') { if ($this->type == 'supergroup') {
return true; return true;
} else {
return false;
} }
return false;
} }
public function isChannel() public function isChannel()
{ {
if ($this->type == 'channel') { if ($this->type == 'channel') {
return true; return true;
} else {
return false;
} }
return false;
} }
public function getId() public function getId()
......
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