File tree Expand file tree Collapse file tree 5 files changed +11
-8
lines changed Expand file tree Collapse file tree 5 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -74,11 +74,14 @@ public static function evaluate(mixed $roman): array|int|string
7474 // Convert the roman numeral to an arabic number
7575 $ negativeNumber = $ roman [0 ] === '- ' ;
7676 if ($ negativeNumber ) {
77- $ roman = substr ($ roman , 1 );
77+ $ roman = trim (substr ($ roman , 1 ));
78+ if ($ roman === '' ) {
79+ return ExcelError::NAN ();
80+ }
7881 }
7982
8083 try {
81- $ arabic = self ::calculateArabic (str_split ($ roman ));
84+ $ arabic = self ::calculateArabic (mb_str_split ($ roman ));
8285 } catch (Exception ) {
8386 return ExcelError::VALUE (); // Invalid character detected
8487 }
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ private function findCharSet(string $xml): string
8787 public function scan ($ xml ): string
8888 {
8989 // Don't rely purely on libxml_disable_entity_loader()
90- $ pattern = '/\0* ' . implode ('\0* ' , str_split ($ this ->pattern )) . '\0*/ ' ;
90+ $ pattern = '/\0* ' . implode ('\0* ' , mb_str_split ($ this ->pattern )) . '\0*/ ' ;
9191
9292 $ xml = "$ xml " ;
9393 if (preg_match ($ pattern , $ xml )) {
Original file line number Diff line number Diff line change 1212 ['4886718345 ' , '123456789 ' ],
1313 [ExcelError::NAN (), '123.45 ' ],
1414 ['0 ' , '0 ' ],
15- [11 , 'A2 ' ],
16- [0 , 'A3 ' ],
17- [0 , '' ],
15+ ['0 ' , '' ],
1816 [ExcelError::NAN (), 'G3579A ' ],
1917 [ExcelError::VALUE (), true ],
2018 [ExcelError::VALUE (), false ],
Original file line number Diff line number Diff line change 1515 [ExcelError::NAN (), '3579 ' ],
1616 ['44 ' , '54 ' ],
1717 ['-165 ' , '7777777533 ' ], // 2's Complement
18- ['65 ' , 'A2 ' ],
19- ['0 ' , 'A3 ' ],
2018 ['0 ' , '' ],
2119 [ExcelError::NAN (), '37777777770 ' ], // too many digits
2220 ['536870911 ' , '3777777777 ' ], // highest positive
Original file line number Diff line number Diff line change 6363 0 ,
6464 '' ,
6565 ],
66+ [
67+ '#NUM! ' ,
68+ '- ' ,
69+ ],
6670];
You can’t perform that action at this time.
0 commit comments