Skip to content

Commit

Permalink
Code style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Komarev committed Oct 11, 2023
1 parent 180e509 commit 6cbdd46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Calculator/SvgTextSizeCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ 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;
}

$lineWidth += $font->computeWidth($unicodeCodePoint, $size);
}

$width = max($width, $lineWidth);
$width = \max($width, $lineWidth);

return \round($width + self::SHIELD_PADDING, 1);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Calculator/TextUnicodeConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 6cbdd46

Please sign in to comment.