summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/src/Utilities/StringComparators/SimpleStringComparator.php')
-rw-r--r--MLEB/Translate/src/Utilities/StringComparators/SimpleStringComparator.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/MLEB/Translate/src/Utilities/StringComparators/SimpleStringComparator.php b/MLEB/Translate/src/Utilities/StringComparators/SimpleStringComparator.php
new file mode 100644
index 00000000..1c24d2c8
--- /dev/null
+++ b/MLEB/Translate/src/Utilities/StringComparators/SimpleStringComparator.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Contains a simple string compare class.
+ * @license GPL-2.0-or-later
+ */
+
+namespace MediaWiki\Extensions\Translate\Utilities\StringComparators;
+
+/**
+ * A simple string comparator, that compares two strings and determines if they are an exact match.
+ * @since 2019.10
+ */
+class SimpleStringComparator implements StringComparator {
+ /**
+ * @inheritDoc
+ */
+ public function getSimilarity( $addedMessage, $deletedMessage ) {
+ if ( $addedMessage === $deletedMessage ) {
+ return 1;
+ }
+
+ if ( trim( mb_strtolower( $addedMessage ) ) === trim( mb_strtolower( $deletedMessage ) ) ) {
+ // This is an arbitrarily chosen number to differentiate it from an exact match.
+ return 0.95;
+ }
+
+ return 0;
+ }
+}