fedi-feed-router/app/Services/Article/ValidationService.php

39 lines
907 B
PHP
Raw Normal View History

2025-06-29 19:46:50 +02:00
<?php
namespace App\Services\Article;
use App\Models\Article;
class ValidationService
{
public static function validate(Article $article): Article
{
logger('Checking keywords for article: ' . $article->id);
2025-06-29 21:33:18 +02:00
$articleData = ArticleFetcher::fetchArticleData($article);
$validationResult = self::validateByKeywords($articleData['full_article']);
2025-06-29 19:46:50 +02:00
$article->update([
2025-06-29 21:33:18 +02:00
'is_valid' => $validationResult,
2025-06-29 19:46:50 +02:00
'validated_at' => now(),
]);
return $article->refresh();
}
2025-06-29 21:33:18 +02:00
private static function validateByKeywords(string $full_article): bool
{
$keywords = [
'N-VA', 'Bart De Wever', 'Frank Vandenbroucke',
];
foreach ($keywords as $keyword) {
if (stripos($full_article, $keyword) !== false) {
return true;
}
}
return false;
}
2025-06-29 19:46:50 +02:00
}