47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
namespace Uiharu\Lookup;
|
|
|
|
use Uiharu\Url;
|
|
|
|
class TwitterLookupTweetResult extends TwitterLookupResult {
|
|
private object $tweetInfo;
|
|
|
|
public function __construct(Url $url, object $tweetInfo) {
|
|
parent::__construct($url);
|
|
$this->tweetInfo = $tweetInfo;
|
|
}
|
|
|
|
public function getObjectType(): string {
|
|
return 'twitter:tweet';
|
|
}
|
|
|
|
public function getTwitterTweetId(): string {
|
|
return $this->tweetInfo->data[0]->id;
|
|
}
|
|
|
|
public function hasTitle(): bool {
|
|
return isset($this->tweetInfo->includes->users[0]->name);
|
|
}
|
|
public function getTitle(): string {
|
|
return $this->tweetInfo->includes->users[0]->name;
|
|
}
|
|
|
|
public function hasDescription(): bool {
|
|
return isset($this->tweetInfo->data[0]->text);
|
|
}
|
|
public function getDescription(): string {
|
|
return $this->tweetInfo->data[0]->text;
|
|
}
|
|
|
|
public function hasPreviewImage(): bool {
|
|
return isset($this->tweetInfo->includes->users[0]->profile_image_url);
|
|
}
|
|
public function getPreviewImage(): string {
|
|
return $this->tweetInfo->includes->users[0]->profile_image_url;
|
|
}
|
|
|
|
public function getTwitterResult(): object {
|
|
return $this->tweetInfo;
|
|
}
|
|
}
|