slack/src/Response/Chat.php

49 lines
879 B
PHP

<?php
namespace Slack\Response;
use Carbon\Carbon;
use Illuminate\Support\Collection;
/**
* This is a Slack Response from a GetHistory API call which is a message Chat
*/
final class Chat extends Base
{
private const LOGKEY = 'RC-';
/**
* Enable getting values for keys in the response
*
* @note: This method is limited to certain values to ensure integrity reasons
*/
public function __get($key)
{
switch ($key) {
default:
return parent::__get($key);
}
}
public function getTime(string $ts): Carbon
{
$t = strstr($ts,'.',TRUE);
return Carbon::createFromTimestamp($t);
}
public function replies(): Collection
{
return $this->messages->skip(1);
}
public function reply_count(): int
{
return $this->messages->first()->reply_count;
}
public function user_count(): int
{
return $this->messages->first()->reply_users_count;
}
}