Skip to content

Commit 5fbf210

Browse files
committed
Improved string length calculation
1 parent 3d909a2 commit 5fbf210

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"php": ">=7.4"
2424
},
2525
"require-dev": {
26-
"opis/string": "^2.0",
26+
"opis/string": "^2.1",
2727
"ext-bcmath": "*",
2828
"ext-json": "*",
2929
"ext-mbstring": "*",

src/ValidatorHelper.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ class ValidatorHelper implements IValidatorHelper
3636
public function __construct(int $scale = 10)
3737
{
3838
$this->scale = $scale;
39-
if (class_exists('\\Opis\String\\UnicodeString', true)) {
40-
$this->strLengthFunc = function (string $data): int {
41-
return \Opis\String\UnicodeString::from($data)->length();
42-
};
39+
if (class_exists(\Opis\String\UnicodeString::class, true)) {
40+
$this->strLengthFunc = [\Opis\String\UnicodeString::class, "getStringLength"];
4341
}
4442
else {
4543
$this->strLengthFunc = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen';

0 commit comments

Comments
 (0)