From bb40b60d3eeae4f6e026ba0207426a882a7ba588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Tue, 6 Apr 2021 22:19:23 +0200 Subject: [PATCH] php 7.4 refactor --- app/Models/Thread.php | 2 +- app/Twitter/Tweet.php | 24 ++++++++++++++++++------ app/Twitter/TwitterImage.php | 9 ++++++--- app/Twitter/TwitterUser.php | 20 +++++++++++++++----- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/app/Models/Thread.php b/app/Models/Thread.php index 958ecef..f15e28c 100644 --- a/app/Models/Thread.php +++ b/app/Models/Thread.php @@ -40,7 +40,7 @@ class Thread extends Model return $this->belongsTo(Author::class, 'author_username', 'username'); } - public function getTweetUrlAttribute(): string|null + public function getTweetUrlAttribute(): string { return "https://twitter.com/{$this->author_username}/status/{$this->tweet_id}"; } diff --git a/app/Twitter/Tweet.php b/app/Twitter/Tweet.php index 8072885..2aebc87 100644 --- a/app/Twitter/Tweet.php +++ b/app/Twitter/Tweet.php @@ -9,13 +9,25 @@ use Illuminate\Support\Facades\Http; */ class Tweet { + public string $id; + public string $text; + public TwitterUser $author; + public string|null $threadId = null; + public array $images = []; + public function __construct( - public string $id, - public string $text, - public TwitterUser $author, - public string|null $threadId = null, - public array $images = [], - ) {} + string $id, + string $text, + TwitterUser $author, + string|null $threadId = null, + array $images = [], + ) { + $this->id = $id; + $this->text = $text; + $this->author = $author; + $this->threadId = $threadId; + $this->images = $images; + } /** Fetch a tweet. */ public static function fetch(string $id): Tweet diff --git a/app/Twitter/TwitterImage.php b/app/Twitter/TwitterImage.php index 08ae6b3..1d1699a 100644 --- a/app/Twitter/TwitterImage.php +++ b/app/Twitter/TwitterImage.php @@ -10,9 +10,12 @@ namespace App\Twitter; */ class TwitterImage { - public function __construct( - public string $url, - ) {} + public string $url; + + public function __construct(string $url) + { + $this->url = $url; + } public function __call($size, $args): string { diff --git a/app/Twitter/TwitterUser.php b/app/Twitter/TwitterUser.php index 065f7aa..8f2fa24 100644 --- a/app/Twitter/TwitterUser.php +++ b/app/Twitter/TwitterUser.php @@ -4,10 +4,20 @@ namespace App\Twitter; class TwitterUser { + public string $id; + public string $name; + public string $username; + public string $profile_image_url; + public function __construct( - public string $id, - public string $name, - public string $username, - public string $profile_image_url, - ) {} + string $id, + string $name, + string $username, + string $profile_image_url, + ) { + $this->id = $id; + $this->name = $name; + $this->username = $username; + $this->profile_image_url = $profile_image_url; + } }