From 6cbdd4699eae56bb3e50fdfd5bd80a1fb1249499 Mon Sep 17 00:00:00 2001 From: Anton Komarev Date: Thu, 12 Oct 2023 00:17:49 +0300 Subject: [PATCH] Code style fix --- src/Calculator/SvgTextSizeCalculator.php | 6 +++--- src/Calculator/TextUnicodeConverter.php | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Calculator/SvgTextSizeCalculator.php b/src/Calculator/SvgTextSizeCalculator.php index 5df2408..3881bd1 100644 --- a/src/Calculator/SvgTextSizeCalculator.php +++ b/src/Calculator/SvgTextSizeCalculator.php @@ -31,12 +31,12 @@ public function calculateWidth(string $text, int $size = self::TEXT_SIZE): float $textUnicode = TextUnicodeConverter::convertTextToCodePoints($text); - $width = 0; + $width = 0; $lineWidth = 0; foreach ($textUnicode as $unicodeCodePoint) { if ($unicodeCodePoint === self::UNICODE_CODE_POINT_LINE_FEED) { - $width = max($width, $lineWidth); + $width = \max($width, $lineWidth); $lineWidth = 0; continue; } @@ -44,7 +44,7 @@ public function calculateWidth(string $text, int $size = self::TEXT_SIZE): float $lineWidth += $font->computeWidth($unicodeCodePoint, $size); } - $width = max($width, $lineWidth); + $width = \max($width, $lineWidth); return \round($width + self::SHIELD_PADDING, 1); } diff --git a/src/Calculator/TextUnicodeConverter.php b/src/Calculator/TextUnicodeConverter.php index 9dc19e1..600121c 100644 --- a/src/Calculator/TextUnicodeConverter.php +++ b/src/Calculator/TextUnicodeConverter.php @@ -23,29 +23,29 @@ public static function convertTextToCodePoints( string $string ): array { $codePoints = []; - $values = []; + $values = []; $lookingFor = 1; - for ($i = 0, $iMax = strlen($string); $i < $iMax; $i++) { - $thisValue = ord($string[$i]); + for ($i = 0, $iMax = \strlen($string); $i < $iMax; $i++) { + $thisValue = \ord($string[$i]); if ($thisValue < 128) { $codePoints[] = $thisValue; } else { - if (count($values) === 0) { + if (0 === \count($values)) { $lookingFor = ($thisValue < 224) ? 2 : 3; } $values[] = $thisValue; - if (count($values) === $lookingFor) { + if (\count($values) === $lookingFor) { $number = ($lookingFor === 3) ? (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64) : (($values[0] % 32) * 64) + ($values[1] % 64); $codePoints[] = $number; - $values = []; - $lookingFor = 1; + $values = []; + $lookingFor = 1; } } }