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
74
74
// Convert the roman numeral to an arabic number
75
75
$ negativeNumber = $ roman [0 ] === '- ' ;
76
76
if ($ negativeNumber ) {
77
- $ roman = substr ($ roman , 1 );
77
+ $ roman = trim (substr ($ roman , 1 ));
78
+ if ($ roman === '' ) {
79
+ return ExcelError::NAN ();
80
+ }
78
81
}
79
82
80
83
try {
81
- $ arabic = self ::calculateArabic (str_split ($ roman ));
84
+ $ arabic = self ::calculateArabic (mb_str_split ($ roman ));
82
85
} catch (Exception ) {
83
86
return ExcelError::VALUE (); // Invalid character detected
84
87
}
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ private function findCharSet(string $xml): string
87
87
public function scan ($ xml ): string
88
88
{
89
89
// 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*/ ' ;
91
91
92
92
$ xml = "$ xml " ;
93
93
if (preg_match ($ pattern , $ xml )) {
Original file line number Diff line number Diff line change 12
12
['4886718345 ' , '123456789 ' ],
13
13
[ExcelError::NAN (), '123.45 ' ],
14
14
['0 ' , '0 ' ],
15
- [11 , 'A2 ' ],
16
- [0 , 'A3 ' ],
17
- [0 , '' ],
15
+ ['0 ' , '' ],
18
16
[ExcelError::NAN (), 'G3579A ' ],
19
17
[ExcelError::VALUE (), true ],
20
18
[ExcelError::VALUE (), false ],
Original file line number Diff line number Diff line change 15
15
[ExcelError::NAN (), '3579 ' ],
16
16
['44 ' , '54 ' ],
17
17
['-165 ' , '7777777533 ' ], // 2's Complement
18
- ['65 ' , 'A2 ' ],
19
- ['0 ' , 'A3 ' ],
20
18
['0 ' , '' ],
21
19
[ExcelError::NAN (), '37777777770 ' ], // too many digits
22
20
['536870911 ' , '3777777777 ' ], // highest positive
Original file line number Diff line number Diff line change 63
63
0 ,
64
64
'' ,
65
65
],
66
+ [
67
+ '#NUM! ' ,
68
+ '- ' ,
69
+ ],
66
70
];
You can’t perform that action at this time.
0 commit comments