From 1813c807f1a7c1f37d0fc504d9bbe590386da7dc Mon Sep 17 00:00:00 2001 From: Baspa Date: Fri, 11 Aug 2023 08:40:20 +0000 Subject: [PATCH] Fix styling --- config/seo.php | 4 ++-- .../Content/TransitionWordRatioCheck.php | 19 ++++++++++--------- src/Helpers/TransitionWords.php | 2 +- .../Content/TransitionWordRatioCheckTest.php | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/config/seo.php b/config/seo.php index 35412e5c..c71ed1fe 100644 --- a/config/seo.php +++ b/config/seo.php @@ -8,10 +8,10 @@ |-------------------------------------------------------------------------- | | The following array lists the default options for the application. - | + | */ // en, nl or null (which will use the app locale) - 'language' => null, + 'language' => null, /* |-------------------------------------------------------------------------- diff --git a/src/Checks/Content/TransitionWordRatioCheck.php b/src/Checks/Content/TransitionWordRatioCheck.php index 3c7bba41..da0c6caf 100644 --- a/src/Checks/Content/TransitionWordRatioCheck.php +++ b/src/Checks/Content/TransitionWordRatioCheck.php @@ -3,10 +3,10 @@ namespace Vormkracht10\Seo\Checks\Content; use Illuminate\Http\Client\Response; -use Vormkracht10\Seo\Interfaces\Check; use Symfony\Component\DomCrawler\Crawler; -use Vormkracht10\Seo\Traits\PerformCheck; use Vormkracht10\Seo\Helpers\TransitionWords; +use Vormkracht10\Seo\Interfaces\Check; +use Vormkracht10\Seo\Traits\PerformCheck; class TransitionWordRatioCheck implements Check { @@ -56,13 +56,14 @@ public function validateContent(Crawler $crawler): bool return true; } - public function calculatePercentageOfTransitionWordsInContent($content, $transitionWords) + public function calculatePercentageOfTransitionWordsInContent($content, $transitionWords) { $totalPhrases = preg_match_all('/\b[\w\s]+\b/', $content, $matches); - + if ($totalPhrases === 0) { $this->actualValue = 0; $this->failureReason = __('failed.content.transition_words_ratio_check.no_phrases_found'); + return 0; } @@ -75,18 +76,18 @@ public function calculatePercentageOfTransitionWordsInContent($content, $transit return round($phrasesWithTransitionWord / $totalPhrases * 100, 0, PHP_ROUND_HALF_UP); } - public function calculateNumberOfPhrasesWithTransitionWord(string $content, string $transitionWord): int + public function calculateNumberOfPhrasesWithTransitionWord(string $content, string $transitionWord): int { preg_match_all('/\b[\w\s]+\b/', $content, $matches); - + $phrasesWithTransitionWord = 0; - + foreach ($matches[0] as $phrase) { if (stripos($phrase, $transitionWord) !== false) { $phrasesWithTransitionWord++; } } - + return $phrasesWithTransitionWord; } -} \ No newline at end of file +} diff --git a/src/Helpers/TransitionWords.php b/src/Helpers/TransitionWords.php index c7df4104..6c0a5838 100644 --- a/src/Helpers/TransitionWords.php +++ b/src/Helpers/TransitionWords.php @@ -54,7 +54,7 @@ public static function getTransitionWords(): array return self::$transitionWords; } - public static function getTransitionWordsOnly(?string $locale = null): array + public static function getTransitionWordsOnly(string $locale = null): array { $transitionWords = self::$transitionWords; diff --git a/tests/Checks/Content/TransitionWordRatioCheckTest.php b/tests/Checks/Content/TransitionWordRatioCheckTest.php index b06dd0b2..f77ff821 100644 --- a/tests/Checks/Content/TransitionWordRatioCheckTest.php +++ b/tests/Checks/Content/TransitionWordRatioCheckTest.php @@ -71,4 +71,4 @@ $crawler->addHtmlContent(Http::get('vormkracht10.nl')->body()); $this->assertFalse($check->check(Http::get('vormkracht10.nl'), $crawler)); -}); \ No newline at end of file +});