diff --git a/app/Jobs/PublishToLemmyJob.php b/app/Jobs/PublishToLemmyJob.php index 15bb287..4781811 100644 --- a/app/Jobs/PublishToLemmyJob.php +++ b/app/Jobs/PublishToLemmyJob.php @@ -8,7 +8,6 @@ use App\Services\Publishing\ArticlePublishingService; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; -use RuntimeException; class PublishToLemmyJob implements ShouldQueue { @@ -29,7 +28,7 @@ public function handle(): void try { $publishingService->publishToRoutedChannels($this->article, $extractedData); - } catch (PublishException|RuntimeException $e) { + } catch (PublishException $e) { $this->fail($e); } } diff --git a/app/Jobs/SyncChannelPostsJob.php b/app/Jobs/SyncChannelPostsJob.php index 371db60..04098c6 100644 --- a/app/Jobs/SyncChannelPostsJob.php +++ b/app/Jobs/SyncChannelPostsJob.php @@ -40,9 +40,9 @@ public function handle(): void { LogSaver::info('Starting channel posts sync job', $this->channel); - if ($this->channel->platformInstance->platform === PlatformEnum::LEMMY) { - $this->syncLemmyChannelPosts(); - } + match ($this->channel->platformInstance->platform) { + PlatformEnum::LEMMY => $this->syncLemmyChannelPosts(), + }; LogSaver::info('Channel posts sync job completed', $this->channel); } diff --git a/app/Models/Feed.php b/app/Models/Feed.php index f274453..8628df2 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -16,11 +16,11 @@ * @property string $url * @property string $type * @property int $language_id - * @property Language $language + * @property Language|null $language * @property string $description * @property array $settings * @property bool $is_active - * @property Carbon $last_fetched_at + * @property Carbon|null $last_fetched_at * @property Carbon $created_at * @property Carbon $updated_at * @method static create(array $validated) diff --git a/app/Models/PlatformChannel.php b/app/Models/PlatformChannel.php index 9160496..3023d95 100644 --- a/app/Models/PlatformChannel.php +++ b/app/Models/PlatformChannel.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Enums\PlatformEnum; use Database\Factories\PlatformChannelFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -17,7 +18,7 @@ * @property integer $channel_id * @property string $name * @property int $language_id - * @property Language $language + * @property Language|null $language * @property boolean $is_active */ class PlatformChannel extends Model @@ -60,9 +61,8 @@ public function activePlatformAccounts(): BelongsToMany public function getFullNameAttribute(): string { - // For Lemmy, use /c/ prefix. Other platforms may use different formats - $prefix = $this->platformInstance->platform === 'lemmy' ? '/c/' : '/'; - return $this->platformInstance->url . $prefix . $this->name; + // For Lemmy, use /c/ prefix + return $this->platformInstance->url . '/c/' . $this->name; } public function feeds(): BelongsToMany diff --git a/app/Services/Parsers/BelgaHomepageParser.php b/app/Services/Parsers/BelgaHomepageParser.php index 6a5371d..7f374ef 100644 --- a/app/Services/Parsers/BelgaHomepageParser.php +++ b/app/Services/Parsers/BelgaHomepageParser.php @@ -8,7 +8,7 @@ public static function extractArticleUrls(string $html): array { preg_match_all('/href="(https:\/\/www\.belganewsagency\.eu\/[a-z0-9-]+)"/', $html, $matches); - $urls = collect($matches[1] ?? []) + $urls = collect($matches[1]) ->unique() ->toArray(); diff --git a/app/Services/Parsers/VrtHomepageParser.php b/app/Services/Parsers/VrtHomepageParser.php index 50dbed9..3b47232 100644 --- a/app/Services/Parsers/VrtHomepageParser.php +++ b/app/Services/Parsers/VrtHomepageParser.php @@ -9,7 +9,7 @@ public static function extractArticleUrls(string $html): array // Extract article links using regex preg_match_all('/href="(\/vrtnws\/en\/\d{4}\/\d{2}\/\d{2}\/[^"]+)"/', $html, $matches); - $urls = collect($matches[1] ?? []) + $urls = collect($matches[1]) ->unique() ->map(fn ($path) => 'https://www.vrt.be' . $path) ->toArray(); diff --git a/phpstan.neon b/phpstan.neon index 1a56d53..c4bc952 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,7 @@ includes: - vendor/larastan/larastan/extension.neon parameters: - level: 2 + level: 4 paths: - app/ - tests/