Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
SimpleStringComparator | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
getSimilarity | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | /** |
3 | * Contains a simple string compare class. |
4 | * @license GPL-2.0-or-later |
5 | */ |
6 | |
7 | namespace MediaWiki\Extension\Translate\Utilities\StringComparators; |
8 | |
9 | /** |
10 | * A simple string comparator, that compares two strings and determines if they are an exact match. |
11 | * @since 2019.10 |
12 | */ |
13 | class SimpleStringComparator implements StringComparator { |
14 | /** @inheritDoc */ |
15 | public function getSimilarity( $addedMessage, $deletedMessage ) { |
16 | if ( $addedMessage === $deletedMessage ) { |
17 | return 1; |
18 | } |
19 | |
20 | if ( trim( mb_strtolower( $addedMessage ) ) === trim( mb_strtolower( $deletedMessage ) ) ) { |
21 | // This is an arbitrarily chosen number to differentiate it from an exact match. |
22 | return 0.95; |
23 | } |
24 | |
25 | return 0; |
26 | } |
27 | } |