Skip to content

Commit 70d59e6

Browse files
committed
refactor Russian
1 parent 31ed159 commit 70d59e6

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/Expectations/Profanity.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
declare(strict_types=1);
44

55
use JonPurvis\Profanify\Expectations\TargetedProfanity;
6-
use JonPurvis\Profanify\Support\RussianNormalizer;
6+
use JonPurvis\Profanify\Support\Russian;
77
use Pest\Arch\Contracts\ArchExpectation;
88
use Pest\Arch\Support\FileLineFinder;
99
use PHPUnit\Architecture\Elements\ObjectDescription;
@@ -52,9 +52,8 @@ function (ObjectDescription $object) use (&$foundWords, $excluding, $including,
5252
return true;
5353
}
5454

55-
// Check if russian
56-
if (preg_match('/[А-Яа-яЁё]/u', $word)) {
57-
$normalized = RussianNormalizer::normalize($fileContents);
55+
if (Russian::is($word)) {
56+
$normalized = Russian::normalize($fileContents);
5857

5958
return str_contains($normalized, $word);
6059
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44

55
namespace JonPurvis\Profanify\Support;
66

7-
final class RussianNormalizer
7+
final class Russian
88
{
9+
public static function is(string $text): bool
10+
{
11+
return (bool) preg_match('/[А-Яа-яЁё]/u', $text);
12+
}
13+
914
public static function normalize(string $text): string
1015
{
1116
$text = mb_strtolower(str_replace('ё', 'е', $text), 'UTF-8');

0 commit comments

Comments
 (0)