aboutsummaryrefslogtreecommitdiff
path: root/cli/i18n/I18nUsageValidator.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2022-10-20 17:42:47 -0400
committerGravatar GitHub <noreply@github.com> 2022-10-20 23:42:47 +0200
commit1f4e347cae51667e7cf5772aef55d274a39c8023 (patch)
tree86ba1032c30b581223a7131764d8384f4b566d88 /cli/i18n/I18nUsageValidator.php
parentd4181e098d93379c21251bd94d1397e16e56218a (diff)
Add tests on i18n classes (#4756)
Diffstat (limited to 'cli/i18n/I18nUsageValidator.php')
-rw-r--r--cli/i18n/I18nUsageValidator.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/cli/i18n/I18nUsageValidator.php b/cli/i18n/I18nUsageValidator.php
index 2e402faf0..681e17326 100644
--- a/cli/i18n/I18nUsageValidator.php
+++ b/cli/i18n/I18nUsageValidator.php
@@ -16,6 +16,12 @@ class I18nUsageValidator implements I18nValidatorInterface {
}
public function displayReport() {
+ if ($this->failedEntries > $this->totalEntries) {
+ throw new \RuntimeException('The number of unused strings cannot be higher than the number of strings');
+ }
+ if ($this->totalEntries === 0) {
+ return 'There is no data.' . PHP_EOL;
+ }
return sprintf('%5.1f%% of translation keys are unused.', $this->failedEntries / $this->totalEntries * 100) . PHP_EOL;
}