Added VKBot
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Library\VK\Entity;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class VkPost
|
||||
{
|
||||
private int $id;
|
||||
private bool $post = true;
|
||||
private string $text;
|
||||
private int $author_id;
|
||||
private int $owner_id;
|
||||
private array $attachments = [];
|
||||
private Carbon $date;
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'post' => (int) $this->post,
|
||||
'text' => $this->text,
|
||||
'author_id' => $this->author_id,
|
||||
'owner_id' => $this->owner_id,
|
||||
'date' => $this->getDate()->toIso8601String(),
|
||||
'attachments' => $this->attachments,
|
||||
];
|
||||
}
|
||||
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return empty($this->text);
|
||||
}
|
||||
|
||||
public function isPost(): bool
|
||||
{
|
||||
return $this->post;
|
||||
}
|
||||
|
||||
public function isRepost(): bool
|
||||
{
|
||||
return ! $this->post;
|
||||
}
|
||||
|
||||
public function setIsPost(): void
|
||||
{
|
||||
$this->post = true;
|
||||
}
|
||||
|
||||
public function setIsRepost(): void
|
||||
{
|
||||
$this->post = false;
|
||||
}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getText(): string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function getAuthorId(): int
|
||||
{
|
||||
return $this->author_id;
|
||||
}
|
||||
|
||||
public function getDate(): Carbon
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOwnerId(): int
|
||||
{
|
||||
return $this->owner_id;
|
||||
}
|
||||
|
||||
public function setId(int $id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function setText(string $text): void
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
public function setAuthorId(int $author_id): void
|
||||
{
|
||||
$this->author_id = $author_id;
|
||||
}
|
||||
|
||||
public function setDate(string|int $date): void
|
||||
{
|
||||
$this->date = Carbon::parse($date);
|
||||
}
|
||||
|
||||
public function setOwnerId(int $owner_id): void
|
||||
{
|
||||
$this->owner_id = $owner_id;
|
||||
}
|
||||
|
||||
public function setAttachments(array $attachments = []): void
|
||||
{
|
||||
$this->attachments = $attachments;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user