Skip to content

Commit a7acf98

Browse files
committed
refactor: standardize parameter naming in methods for consistency
1 parent 536ab08 commit a7acf98

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/Aman.php

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct()
7979
$this->lists = array_values(array_map(function (string $str): string {
8080

8181
$replace = strval(preg_replace_callback('/[a-z]/i', function (array $mats): string {
82-
return strval(static::similar[strtolower($mats[0])] ?? $mats[0]);
82+
return strval(static::similar[strtolower(strval($mats[0]))] ?? $mats[0]);
8383
}, $str));
8484

8585
return '/\b' . $replace . '\b/iu';
@@ -125,13 +125,13 @@ public static function factory(): Aman
125125
/**
126126
* Check if contains.
127127
*
128-
* @param string $string
128+
* @param string $str
129129
* @return bool
130130
*/
131-
public function check(string $string): bool
131+
public function check(string $str): bool
132132
{
133133
foreach ($this->lists as $pattern) {
134-
if (preg_match($pattern, $string)) {
134+
if (preg_match($pattern, $str)) {
135135
return true;
136136
}
137137
}
@@ -142,43 +142,40 @@ public function check(string $string): bool
142142
/**
143143
* Mask contains word.
144144
*
145-
* @param string $string
145+
* @param string $str
146146
* @param string $masking
147147
* @return string
148148
*/
149-
public function masking(string $string, string $masking = '*'): string
149+
public function masking(string $str, string $masking = '*'): string
150150
{
151151
return strval(preg_replace_callback($this->lists, function (array $words) use ($masking): string {
152-
return str_repeat($masking, strlen($words[0]));
153-
}, $string));
152+
return str_repeat($masking, strlen(strval($words[0])));
153+
}, $str));
154154
}
155155

156156
/**
157157
* Filter and remove if contains.
158158
*
159-
* @param string $string
159+
* @param string $str
160160
* @return string
161161
*/
162-
public function filter(string $string): string
162+
public function filter(string $str): string
163163
{
164-
return strval(preg_replace_callback($this->lists, function (): string {
165-
return '';
166-
}, $string));
164+
return strval(preg_replace_callback($this->lists, fn(): string => '', $str));
167165
}
168166

169167
/**
170168
* Get from string.
171169
*
172-
* @param string $string
170+
* @param string $str
173171
* @return array<int, string>
174172
*/
175-
public function words(string $string): array
173+
public function words(string $str): array
176174
{
177175
$lists = [];
178-
preg_replace_callback($this->lists, function (array $words) use (&$lists): string {
179-
$lists[] = $words[0];
180-
return $words[0];
181-
}, $string);
176+
preg_replace_callback($this->lists, function (array $mats) use (&$lists): void {
177+
$lists[] = strval($mats[0]);
178+
}, $str);
182179

183180
return $lists;
184181
}

0 commit comments

Comments
 (0)