Convert math module to static Math class

This commit is contained in:
2026-11-23 10:22:11 +01:00
parent c981572bae
commit 2243557bf5
6 changed files with 865 additions and 861 deletions
+4 -2
View File
@@ -1,11 +1,13 @@
import 'math';
class Program {
private string center_text(string $word){
int $tot_width = 30;
char $symbol = '-';
int $middle = (int) round($tot_width/2);
int $middle = (int) Math::Round($tot_width/2);
int $length_word = strlen($word);
int $middle_word = (int) round($length_word / 2);
int $middle_word = (int) Math::Round($length_word / 2);
int $last_position = $middle + $middle_word;
int $number_of_spaces = $middle - $middle_word;
string $result = sprintf("%'{$symbol}{$last_position}s", $word);