ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Roman.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
8 class Roman
9 {
10  private const VALUES = [
11  45 => ['VL'],
12  46 => ['VLI'],
13  47 => ['VLII'],
14  48 => ['VLIII'],
15  49 => ['VLIV', 'IL'],
16  95 => ['VC'],
17  96 => ['VCI'],
18  97 => ['VCII'],
19  98 => ['VCIII'],
20  99 => ['VCIV', 'IC'],
21  145 => ['CVL'],
22  146 => ['CVLI'],
23  147 => ['CVLII'],
24  148 => ['CVLIII'],
25  149 => ['CVLIV', 'CIL'],
26  195 => ['CVC'],
27  196 => ['CVCI'],
28  197 => ['CVCII'],
29  198 => ['CVCIII'],
30  199 => ['CVCIV', 'CIC'],
31  245 => ['CCVL'],
32  246 => ['CCVLI'],
33  247 => ['CCVLII'],
34  248 => ['CCVLIII'],
35  249 => ['CCVLIV', 'CCIL'],
36  295 => ['CCVC'],
37  296 => ['CCVCI'],
38  297 => ['CCVCII'],
39  298 => ['CCVCIII'],
40  299 => ['CCVCIV', 'CCIC'],
41  345 => ['CCCVL'],
42  346 => ['CCCVLI'],
43  347 => ['CCCVLII'],
44  348 => ['CCCVLIII'],
45  349 => ['CCCVLIV', 'CCCIL'],
46  395 => ['CCCVC'],
47  396 => ['CCCVCI'],
48  397 => ['CCCVCII'],
49  398 => ['CCCVCIII'],
50  399 => ['CCCVCIV', 'CCCIC'],
51  445 => ['CDVL'],
52  446 => ['CDVLI'],
53  447 => ['CDVLII'],
54  448 => ['CDVLIII'],
55  449 => ['CDVLIV', 'CDIL'],
56  450 => ['LD'],
57  451 => ['LDI'],
58  452 => ['LDII'],
59  453 => ['LDIII'],
60  454 => ['LDIV'],
61  455 => ['LDV'],
62  456 => ['LDVI'],
63  457 => ['LDVII'],
64  458 => ['LDVIII'],
65  459 => ['LDIX'],
66  460 => ['LDX'],
67  461 => ['LDXI'],
68  462 => ['LDXII'],
69  463 => ['LDXIII'],
70  464 => ['LDXIV'],
71  465 => ['LDXV'],
72  466 => ['LDXVI'],
73  467 => ['LDXVII'],
74  468 => ['LDXVIII'],
75  469 => ['LDXIX'],
76  470 => ['LDXX'],
77  471 => ['LDXXI'],
78  472 => ['LDXXII'],
79  473 => ['LDXXIII'],
80  474 => ['LDXXIV'],
81  475 => ['LDXXV'],
82  476 => ['LDXXVI'],
83  477 => ['LDXXVII'],
84  478 => ['LDXXVIII'],
85  479 => ['LDXXIX'],
86  480 => ['LDXXX'],
87  481 => ['LDXXXI'],
88  482 => ['LDXXXII'],
89  483 => ['LDXXXIII'],
90  484 => ['LDXXXIV'],
91  485 => ['LDXXXV'],
92  486 => ['LDXXXVI'],
93  487 => ['LDXXXVII'],
94  488 => ['LDXXXVIII'],
95  489 => ['LDXXXIX'],
96  490 => ['LDXL', 'XD'],
97  491 => ['LDXLI', 'XDI'],
98  492 => ['LDXLII', 'XDII'],
99  493 => ['LDXLIII', 'XDIII'],
100  494 => ['LDXLIV', 'XDIV'],
101  495 => ['LDVL', 'XDV', 'VD'],
102  496 => ['LDVLI', 'XDVI', 'VDI'],
103  497 => ['LDVLII', 'XDVII', 'VDII'],
104  498 => ['LDVLIII', 'XDVIII', 'VDIII'],
105  499 => ['LDVLIV', 'XDIX', 'VDIV', 'ID'],
106  545 => ['DVL'],
107  546 => ['DVLI'],
108  547 => ['DVLII'],
109  548 => ['DVLIII'],
110  549 => ['DVLIV', 'DIL'],
111  595 => ['DVC'],
112  596 => ['DVCI'],
113  597 => ['DVCII'],
114  598 => ['DVCIII'],
115  599 => ['DVCIV', 'DIC'],
116  645 => ['DCVL'],
117  646 => ['DCVLI'],
118  647 => ['DCVLII'],
119  648 => ['DCVLIII'],
120  649 => ['DCVLIV', 'DCIL'],
121  695 => ['DCVC'],
122  696 => ['DCVCI'],
123  697 => ['DCVCII'],
124  698 => ['DCVCIII'],
125  699 => ['DCVCIV', 'DCIC'],
126  745 => ['DCCVL'],
127  746 => ['DCCVLI'],
128  747 => ['DCCVLII'],
129  748 => ['DCCVLIII'],
130  749 => ['DCCVLIV', 'DCCIL'],
131  795 => ['DCCVC'],
132  796 => ['DCCVCI'],
133  797 => ['DCCVCII'],
134  798 => ['DCCVCIII'],
135  799 => ['DCCVCIV', 'DCCIC'],
136  845 => ['DCCCVL'],
137  846 => ['DCCCVLI'],
138  847 => ['DCCCVLII'],
139  848 => ['DCCCVLIII'],
140  849 => ['DCCCVLIV', 'DCCCIL'],
141  895 => ['DCCCVC'],
142  896 => ['DCCCVCI'],
143  897 => ['DCCCVCII'],
144  898 => ['DCCCVCIII'],
145  899 => ['DCCCVCIV', 'DCCCIC'],
146  945 => ['CMVL'],
147  946 => ['CMVLI'],
148  947 => ['CMVLII'],
149  948 => ['CMVLIII'],
150  949 => ['CMVLIV', 'CMIL'],
151  950 => ['LM'],
152  951 => ['LMI'],
153  952 => ['LMII'],
154  953 => ['LMIII'],
155  954 => ['LMIV'],
156  955 => ['LMV'],
157  956 => ['LMVI'],
158  957 => ['LMVII'],
159  958 => ['LMVIII'],
160  959 => ['LMIX'],
161  960 => ['LMX'],
162  961 => ['LMXI'],
163  962 => ['LMXII'],
164  963 => ['LMXIII'],
165  964 => ['LMXIV'],
166  965 => ['LMXV'],
167  966 => ['LMXVI'],
168  967 => ['LMXVII'],
169  968 => ['LMXVIII'],
170  969 => ['LMXIX'],
171  970 => ['LMXX'],
172  971 => ['LMXXI'],
173  972 => ['LMXXII'],
174  973 => ['LMXXIII'],
175  974 => ['LMXXIV'],
176  975 => ['LMXXV'],
177  976 => ['LMXXVI'],
178  977 => ['LMXXVII'],
179  978 => ['LMXXVIII'],
180  979 => ['LMXXIX'],
181  980 => ['LMXXX'],
182  981 => ['LMXXXI'],
183  982 => ['LMXXXII'],
184  983 => ['LMXXXIII'],
185  984 => ['LMXXXIV'],
186  985 => ['LMXXXV'],
187  986 => ['LMXXXVI'],
188  987 => ['LMXXXVII'],
189  988 => ['LMXXXVIII'],
190  989 => ['LMXXXIX'],
191  990 => ['LMXL', 'XM'],
192  991 => ['LMXLI', 'XMI'],
193  992 => ['LMXLII', 'XMII'],
194  993 => ['LMXLIII', 'XMIII'],
195  994 => ['LMXLIV', 'XMIV'],
196  995 => ['LMVL', 'XMV', 'VM'],
197  996 => ['LMVLI', 'XMVI', 'VMI'],
198  997 => ['LMVLII', 'XMVII', 'VMII'],
199  998 => ['LMVLIII', 'XMVIII', 'VMIII'],
200  999 => ['LMVLIV', 'XMIX', 'VMIV', 'IM'],
201  1045 => ['MVL'],
202  1046 => ['MVLI'],
203  1047 => ['MVLII'],
204  1048 => ['MVLIII'],
205  1049 => ['MVLIV', 'MIL'],
206  1095 => ['MVC'],
207  1096 => ['MVCI'],
208  1097 => ['MVCII'],
209  1098 => ['MVCIII'],
210  1099 => ['MVCIV', 'MIC'],
211  1145 => ['MCVL'],
212  1146 => ['MCVLI'],
213  1147 => ['MCVLII'],
214  1148 => ['MCVLIII'],
215  1149 => ['MCVLIV', 'MCIL'],
216  1195 => ['MCVC'],
217  1196 => ['MCVCI'],
218  1197 => ['MCVCII'],
219  1198 => ['MCVCIII'],
220  1199 => ['MCVCIV', 'MCIC'],
221  1245 => ['MCCVL'],
222  1246 => ['MCCVLI'],
223  1247 => ['MCCVLII'],
224  1248 => ['MCCVLIII'],
225  1249 => ['MCCVLIV', 'MCCIL'],
226  1295 => ['MCCVC'],
227  1296 => ['MCCVCI'],
228  1297 => ['MCCVCII'],
229  1298 => ['MCCVCIII'],
230  1299 => ['MCCVCIV', 'MCCIC'],
231  1345 => ['MCCCVL'],
232  1346 => ['MCCCVLI'],
233  1347 => ['MCCCVLII'],
234  1348 => ['MCCCVLIII'],
235  1349 => ['MCCCVLIV', 'MCCCIL'],
236  1395 => ['MCCCVC'],
237  1396 => ['MCCCVCI'],
238  1397 => ['MCCCVCII'],
239  1398 => ['MCCCVCIII'],
240  1399 => ['MCCCVCIV', 'MCCCIC'],
241  1445 => ['MCDVL'],
242  1446 => ['MCDVLI'],
243  1447 => ['MCDVLII'],
244  1448 => ['MCDVLIII'],
245  1449 => ['MCDVLIV', 'MCDIL'],
246  1450 => ['MLD'],
247  1451 => ['MLDI'],
248  1452 => ['MLDII'],
249  1453 => ['MLDIII'],
250  1454 => ['MLDIV'],
251  1455 => ['MLDV'],
252  1456 => ['MLDVI'],
253  1457 => ['MLDVII'],
254  1458 => ['MLDVIII'],
255  1459 => ['MLDIX'],
256  1460 => ['MLDX'],
257  1461 => ['MLDXI'],
258  1462 => ['MLDXII'],
259  1463 => ['MLDXIII'],
260  1464 => ['MLDXIV'],
261  1465 => ['MLDXV'],
262  1466 => ['MLDXVI'],
263  1467 => ['MLDXVII'],
264  1468 => ['MLDXVIII'],
265  1469 => ['MLDXIX'],
266  1470 => ['MLDXX'],
267  1471 => ['MLDXXI'],
268  1472 => ['MLDXXII'],
269  1473 => ['MLDXXIII'],
270  1474 => ['MLDXXIV'],
271  1475 => ['MLDXXV'],
272  1476 => ['MLDXXVI'],
273  1477 => ['MLDXXVII'],
274  1478 => ['MLDXXVIII'],
275  1479 => ['MLDXXIX'],
276  1480 => ['MLDXXX'],
277  1481 => ['MLDXXXI'],
278  1482 => ['MLDXXXII'],
279  1483 => ['MLDXXXIII'],
280  1484 => ['MLDXXXIV'],
281  1485 => ['MLDXXXV'],
282  1486 => ['MLDXXXVI'],
283  1487 => ['MLDXXXVII'],
284  1488 => ['MLDXXXVIII'],
285  1489 => ['MLDXXXIX'],
286  1490 => ['MLDXL', 'MXD'],
287  1491 => ['MLDXLI', 'MXDI'],
288  1492 => ['MLDXLII', 'MXDII'],
289  1493 => ['MLDXLIII', 'MXDIII'],
290  1494 => ['MLDXLIV', 'MXDIV'],
291  1495 => ['MLDVL', 'MXDV', 'MVD'],
292  1496 => ['MLDVLI', 'MXDVI', 'MVDI'],
293  1497 => ['MLDVLII', 'MXDVII', 'MVDII'],
294  1498 => ['MLDVLIII', 'MXDVIII', 'MVDIII'],
295  1499 => ['MLDVLIV', 'MXDIX', 'MVDIV', 'MID'],
296  1545 => ['MDVL'],
297  1546 => ['MDVLI'],
298  1547 => ['MDVLII'],
299  1548 => ['MDVLIII'],
300  1549 => ['MDVLIV', 'MDIL'],
301  1595 => ['MDVC'],
302  1596 => ['MDVCI'],
303  1597 => ['MDVCII'],
304  1598 => ['MDVCIII'],
305  1599 => ['MDVCIV', 'MDIC'],
306  1645 => ['MDCVL'],
307  1646 => ['MDCVLI'],
308  1647 => ['MDCVLII'],
309  1648 => ['MDCVLIII'],
310  1649 => ['MDCVLIV', 'MDCIL'],
311  1695 => ['MDCVC'],
312  1696 => ['MDCVCI'],
313  1697 => ['MDCVCII'],
314  1698 => ['MDCVCIII'],
315  1699 => ['MDCVCIV', 'MDCIC'],
316  1745 => ['MDCCVL'],
317  1746 => ['MDCCVLI'],
318  1747 => ['MDCCVLII'],
319  1748 => ['MDCCVLIII'],
320  1749 => ['MDCCVLIV', 'MDCCIL'],
321  1795 => ['MDCCVC'],
322  1796 => ['MDCCVCI'],
323  1797 => ['MDCCVCII'],
324  1798 => ['MDCCVCIII'],
325  1799 => ['MDCCVCIV', 'MDCCIC'],
326  1845 => ['MDCCCVL'],
327  1846 => ['MDCCCVLI'],
328  1847 => ['MDCCCVLII'],
329  1848 => ['MDCCCVLIII'],
330  1849 => ['MDCCCVLIV', 'MDCCCIL'],
331  1895 => ['MDCCCVC'],
332  1896 => ['MDCCCVCI'],
333  1897 => ['MDCCCVCII'],
334  1898 => ['MDCCCVCIII'],
335  1899 => ['MDCCCVCIV', 'MDCCCIC'],
336  1945 => ['MCMVL'],
337  1946 => ['MCMVLI'],
338  1947 => ['MCMVLII'],
339  1948 => ['MCMVLIII'],
340  1949 => ['MCMVLIV', 'MCMIL'],
341  1950 => ['MLM'],
342  1951 => ['MLMI'],
343  1952 => ['MLMII'],
344  1953 => ['MLMIII'],
345  1954 => ['MLMIV'],
346  1955 => ['MLMV'],
347  1956 => ['MLMVI'],
348  1957 => ['MLMVII'],
349  1958 => ['MLMVIII'],
350  1959 => ['MLMIX'],
351  1960 => ['MLMX'],
352  1961 => ['MLMXI'],
353  1962 => ['MLMXII'],
354  1963 => ['MLMXIII'],
355  1964 => ['MLMXIV'],
356  1965 => ['MLMXV'],
357  1966 => ['MLMXVI'],
358  1967 => ['MLMXVII'],
359  1968 => ['MLMXVIII'],
360  1969 => ['MLMXIX'],
361  1970 => ['MLMXX'],
362  1971 => ['MLMXXI'],
363  1972 => ['MLMXXII'],
364  1973 => ['MLMXXIII'],
365  1974 => ['MLMXXIV'],
366  1975 => ['MLMXXV'],
367  1976 => ['MLMXXVI'],
368  1977 => ['MLMXXVII'],
369  1978 => ['MLMXXVIII'],
370  1979 => ['MLMXXIX'],
371  1980 => ['MLMXXX'],
372  1981 => ['MLMXXXI'],
373  1982 => ['MLMXXXII'],
374  1983 => ['MLMXXXIII'],
375  1984 => ['MLMXXXIV'],
376  1985 => ['MLMXXXV'],
377  1986 => ['MLMXXXVI'],
378  1987 => ['MLMXXXVII'],
379  1988 => ['MLMXXXVIII'],
380  1989 => ['MLMXXXIX'],
381  1990 => ['MLMXL', 'MXM'],
382  1991 => ['MLMXLI', 'MXMI'],
383  1992 => ['MLMXLII', 'MXMII'],
384  1993 => ['MLMXLIII', 'MXMIII'],
385  1994 => ['MLMXLIV', 'MXMIV'],
386  1995 => ['MLMVL', 'MXMV', 'MVM'],
387  1996 => ['MLMVLI', 'MXMVI', 'MVMI'],
388  1997 => ['MLMVLII', 'MXMVII', 'MVMII'],
389  1998 => ['MLMVLIII', 'MXMVIII', 'MVMIII'],
390  1999 => ['MLMVLIV', 'MXMIX', 'MVMIV', 'MIM'],
391  2045 => ['MMVL'],
392  2046 => ['MMVLI'],
393  2047 => ['MMVLII'],
394  2048 => ['MMVLIII'],
395  2049 => ['MMVLIV', 'MMIL'],
396  2095 => ['MMVC'],
397  2096 => ['MMVCI'],
398  2097 => ['MMVCII'],
399  2098 => ['MMVCIII'],
400  2099 => ['MMVCIV', 'MMIC'],
401  2145 => ['MMCVL'],
402  2146 => ['MMCVLI'],
403  2147 => ['MMCVLII'],
404  2148 => ['MMCVLIII'],
405  2149 => ['MMCVLIV', 'MMCIL'],
406  2195 => ['MMCVC'],
407  2196 => ['MMCVCI'],
408  2197 => ['MMCVCII'],
409  2198 => ['MMCVCIII'],
410  2199 => ['MMCVCIV', 'MMCIC'],
411  2245 => ['MMCCVL'],
412  2246 => ['MMCCVLI'],
413  2247 => ['MMCCVLII'],
414  2248 => ['MMCCVLIII'],
415  2249 => ['MMCCVLIV', 'MMCCIL'],
416  2295 => ['MMCCVC'],
417  2296 => ['MMCCVCI'],
418  2297 => ['MMCCVCII'],
419  2298 => ['MMCCVCIII'],
420  2299 => ['MMCCVCIV', 'MMCCIC'],
421  2345 => ['MMCCCVL'],
422  2346 => ['MMCCCVLI'],
423  2347 => ['MMCCCVLII'],
424  2348 => ['MMCCCVLIII'],
425  2349 => ['MMCCCVLIV', 'MMCCCIL'],
426  2395 => ['MMCCCVC'],
427  2396 => ['MMCCCVCI'],
428  2397 => ['MMCCCVCII'],
429  2398 => ['MMCCCVCIII'],
430  2399 => ['MMCCCVCIV', 'MMCCCIC'],
431  2445 => ['MMCDVL'],
432  2446 => ['MMCDVLI'],
433  2447 => ['MMCDVLII'],
434  2448 => ['MMCDVLIII'],
435  2449 => ['MMCDVLIV', 'MMCDIL'],
436  2450 => ['MMLD'],
437  2451 => ['MMLDI'],
438  2452 => ['MMLDII'],
439  2453 => ['MMLDIII'],
440  2454 => ['MMLDIV'],
441  2455 => ['MMLDV'],
442  2456 => ['MMLDVI'],
443  2457 => ['MMLDVII'],
444  2458 => ['MMLDVIII'],
445  2459 => ['MMLDIX'],
446  2460 => ['MMLDX'],
447  2461 => ['MMLDXI'],
448  2462 => ['MMLDXII'],
449  2463 => ['MMLDXIII'],
450  2464 => ['MMLDXIV'],
451  2465 => ['MMLDXV'],
452  2466 => ['MMLDXVI'],
453  2467 => ['MMLDXVII'],
454  2468 => ['MMLDXVIII'],
455  2469 => ['MMLDXIX'],
456  2470 => ['MMLDXX'],
457  2471 => ['MMLDXXI'],
458  2472 => ['MMLDXXII'],
459  2473 => ['MMLDXXIII'],
460  2474 => ['MMLDXXIV'],
461  2475 => ['MMLDXXV'],
462  2476 => ['MMLDXXVI'],
463  2477 => ['MMLDXXVII'],
464  2478 => ['MMLDXXVIII'],
465  2479 => ['MMLDXXIX'],
466  2480 => ['MMLDXXX'],
467  2481 => ['MMLDXXXI'],
468  2482 => ['MMLDXXXII'],
469  2483 => ['MMLDXXXIII'],
470  2484 => ['MMLDXXXIV'],
471  2485 => ['MMLDXXXV'],
472  2486 => ['MMLDXXXVI'],
473  2487 => ['MMLDXXXVII'],
474  2488 => ['MMLDXXXVIII'],
475  2489 => ['MMLDXXXIX'],
476  2490 => ['MMLDXL', 'MMXD'],
477  2491 => ['MMLDXLI', 'MMXDI'],
478  2492 => ['MMLDXLII', 'MMXDII'],
479  2493 => ['MMLDXLIII', 'MMXDIII'],
480  2494 => ['MMLDXLIV', 'MMXDIV'],
481  2495 => ['MMLDVL', 'MMXDV', 'MMVD'],
482  2496 => ['MMLDVLI', 'MMXDVI', 'MMVDI'],
483  2497 => ['MMLDVLII', 'MMXDVII', 'MMVDII'],
484  2498 => ['MMLDVLIII', 'MMXDVIII', 'MMVDIII'],
485  2499 => ['MMLDVLIV', 'MMXDIX', 'MMVDIV', 'MMID'],
486  2545 => ['MMDVL'],
487  2546 => ['MMDVLI'],
488  2547 => ['MMDVLII'],
489  2548 => ['MMDVLIII'],
490  2549 => ['MMDVLIV', 'MMDIL'],
491  2595 => ['MMDVC'],
492  2596 => ['MMDVCI'],
493  2597 => ['MMDVCII'],
494  2598 => ['MMDVCIII'],
495  2599 => ['MMDVCIV', 'MMDIC'],
496  2645 => ['MMDCVL'],
497  2646 => ['MMDCVLI'],
498  2647 => ['MMDCVLII'],
499  2648 => ['MMDCVLIII'],
500  2649 => ['MMDCVLIV', 'MMDCIL'],
501  2695 => ['MMDCVC'],
502  2696 => ['MMDCVCI'],
503  2697 => ['MMDCVCII'],
504  2698 => ['MMDCVCIII'],
505  2699 => ['MMDCVCIV', 'MMDCIC'],
506  2745 => ['MMDCCVL'],
507  2746 => ['MMDCCVLI'],
508  2747 => ['MMDCCVLII'],
509  2748 => ['MMDCCVLIII'],
510  2749 => ['MMDCCVLIV', 'MMDCCIL'],
511  2795 => ['MMDCCVC'],
512  2796 => ['MMDCCVCI'],
513  2797 => ['MMDCCVCII'],
514  2798 => ['MMDCCVCIII'],
515  2799 => ['MMDCCVCIV', 'MMDCCIC'],
516  2845 => ['MMDCCCVL'],
517  2846 => ['MMDCCCVLI'],
518  2847 => ['MMDCCCVLII'],
519  2848 => ['MMDCCCVLIII'],
520  2849 => ['MMDCCCVLIV', 'MMDCCCIL'],
521  2895 => ['MMDCCCVC'],
522  2896 => ['MMDCCCVCI'],
523  2897 => ['MMDCCCVCII'],
524  2898 => ['MMDCCCVCIII'],
525  2899 => ['MMDCCCVCIV', 'MMDCCCIC'],
526  2945 => ['MMCMVL'],
527  2946 => ['MMCMVLI'],
528  2947 => ['MMCMVLII'],
529  2948 => ['MMCMVLIII'],
530  2949 => ['MMCMVLIV', 'MMCMIL'],
531  2950 => ['MMLM'],
532  2951 => ['MMLMI'],
533  2952 => ['MMLMII'],
534  2953 => ['MMLMIII'],
535  2954 => ['MMLMIV'],
536  2955 => ['MMLMV'],
537  2956 => ['MMLMVI'],
538  2957 => ['MMLMVII'],
539  2958 => ['MMLMVIII'],
540  2959 => ['MMLMIX'],
541  2960 => ['MMLMX'],
542  2961 => ['MMLMXI'],
543  2962 => ['MMLMXII'],
544  2963 => ['MMLMXIII'],
545  2964 => ['MMLMXIV'],
546  2965 => ['MMLMXV'],
547  2966 => ['MMLMXVI'],
548  2967 => ['MMLMXVII'],
549  2968 => ['MMLMXVIII'],
550  2969 => ['MMLMXIX'],
551  2970 => ['MMLMXX'],
552  2971 => ['MMLMXXI'],
553  2972 => ['MMLMXXII'],
554  2973 => ['MMLMXXIII'],
555  2974 => ['MMLMXXIV'],
556  2975 => ['MMLMXXV'],
557  2976 => ['MMLMXXVI'],
558  2977 => ['MMLMXXVII'],
559  2978 => ['MMLMXXVIII'],
560  2979 => ['MMLMXXIX'],
561  2980 => ['MMLMXXX'],
562  2981 => ['MMLMXXXI'],
563  2982 => ['MMLMXXXII'],
564  2983 => ['MMLMXXXIII'],
565  2984 => ['MMLMXXXIV'],
566  2985 => ['MMLMXXXV'],
567  2986 => ['MMLMXXXVI'],
568  2987 => ['MMLMXXXVII'],
569  2988 => ['MMLMXXXVIII'],
570  2989 => ['MMLMXXXIX'],
571  2990 => ['MMLMXL', 'MMXM'],
572  2991 => ['MMLMXLI', 'MMXMI'],
573  2992 => ['MMLMXLII', 'MMXMII'],
574  2993 => ['MMLMXLIII', 'MMXMIII'],
575  2994 => ['MMLMXLIV', 'MMXMIV'],
576  2995 => ['MMLMVL', 'MMXMV', 'MMVM'],
577  2996 => ['MMLMVLI', 'MMXMVI', 'MMVMI'],
578  2997 => ['MMLMVLII', 'MMXMVII', 'MMVMII'],
579  2998 => ['MMLMVLIII', 'MMXMVIII', 'MMVMIII'],
580  2999 => ['MMLMVLIV', 'MMXMIX', 'MMVMIV', 'MMIM'],
581  3045 => ['MMMVL'],
582  3046 => ['MMMVLI'],
583  3047 => ['MMMVLII'],
584  3048 => ['MMMVLIII'],
585  3049 => ['MMMVLIV', 'MMMIL'],
586  3095 => ['MMMVC'],
587  3096 => ['MMMVCI'],
588  3097 => ['MMMVCII'],
589  3098 => ['MMMVCIII'],
590  3099 => ['MMMVCIV', 'MMMIC'],
591  3145 => ['MMMCVL'],
592  3146 => ['MMMCVLI'],
593  3147 => ['MMMCVLII'],
594  3148 => ['MMMCVLIII'],
595  3149 => ['MMMCVLIV', 'MMMCIL'],
596  3195 => ['MMMCVC'],
597  3196 => ['MMMCVCI'],
598  3197 => ['MMMCVCII'],
599  3198 => ['MMMCVCIII'],
600  3199 => ['MMMCVCIV', 'MMMCIC'],
601  3245 => ['MMMCCVL'],
602  3246 => ['MMMCCVLI'],
603  3247 => ['MMMCCVLII'],
604  3248 => ['MMMCCVLIII'],
605  3249 => ['MMMCCVLIV', 'MMMCCIL'],
606  3295 => ['MMMCCVC'],
607  3296 => ['MMMCCVCI'],
608  3297 => ['MMMCCVCII'],
609  3298 => ['MMMCCVCIII'],
610  3299 => ['MMMCCVCIV', 'MMMCCIC'],
611  3345 => ['MMMCCCVL'],
612  3346 => ['MMMCCCVLI'],
613  3347 => ['MMMCCCVLII'],
614  3348 => ['MMMCCCVLIII'],
615  3349 => ['MMMCCCVLIV', 'MMMCCCIL'],
616  3395 => ['MMMCCCVC'],
617  3396 => ['MMMCCCVCI'],
618  3397 => ['MMMCCCVCII'],
619  3398 => ['MMMCCCVCIII'],
620  3399 => ['MMMCCCVCIV', 'MMMCCCIC'],
621  3445 => ['MMMCDVL'],
622  3446 => ['MMMCDVLI'],
623  3447 => ['MMMCDVLII'],
624  3448 => ['MMMCDVLIII'],
625  3449 => ['MMMCDVLIV', 'MMMCDIL'],
626  3450 => ['MMMLD'],
627  3451 => ['MMMLDI'],
628  3452 => ['MMMLDII'],
629  3453 => ['MMMLDIII'],
630  3454 => ['MMMLDIV'],
631  3455 => ['MMMLDV'],
632  3456 => ['MMMLDVI'],
633  3457 => ['MMMLDVII'],
634  3458 => ['MMMLDVIII'],
635  3459 => ['MMMLDIX'],
636  3460 => ['MMMLDX'],
637  3461 => ['MMMLDXI'],
638  3462 => ['MMMLDXII'],
639  3463 => ['MMMLDXIII'],
640  3464 => ['MMMLDXIV'],
641  3465 => ['MMMLDXV'],
642  3466 => ['MMMLDXVI'],
643  3467 => ['MMMLDXVII'],
644  3468 => ['MMMLDXVIII'],
645  3469 => ['MMMLDXIX'],
646  3470 => ['MMMLDXX'],
647  3471 => ['MMMLDXXI'],
648  3472 => ['MMMLDXXII'],
649  3473 => ['MMMLDXXIII'],
650  3474 => ['MMMLDXXIV'],
651  3475 => ['MMMLDXXV'],
652  3476 => ['MMMLDXXVI'],
653  3477 => ['MMMLDXXVII'],
654  3478 => ['MMMLDXXVIII'],
655  3479 => ['MMMLDXXIX'],
656  3480 => ['MMMLDXXX'],
657  3481 => ['MMMLDXXXI'],
658  3482 => ['MMMLDXXXII'],
659  3483 => ['MMMLDXXXIII'],
660  3484 => ['MMMLDXXXIV'],
661  3485 => ['MMMLDXXXV'],
662  3486 => ['MMMLDXXXVI'],
663  3487 => ['MMMLDXXXVII'],
664  3488 => ['MMMLDXXXVIII'],
665  3489 => ['MMMLDXXXIX'],
666  3490 => ['MMMLDXL', 'MMMXD'],
667  3491 => ['MMMLDXLI', 'MMMXDI'],
668  3492 => ['MMMLDXLII', 'MMMXDII'],
669  3493 => ['MMMLDXLIII', 'MMMXDIII'],
670  3494 => ['MMMLDXLIV', 'MMMXDIV'],
671  3495 => ['MMMLDVL', 'MMMXDV', 'MMMVD'],
672  3496 => ['MMMLDVLI', 'MMMXDVI', 'MMMVDI'],
673  3497 => ['MMMLDVLII', 'MMMXDVII', 'MMMVDII'],
674  3498 => ['MMMLDVLIII', 'MMMXDVIII', 'MMMVDIII'],
675  3499 => ['MMMLDVLIV', 'MMMXDIX', 'MMMVDIV', 'MMMID'],
676  3545 => ['MMMDVL'],
677  3546 => ['MMMDVLI'],
678  3547 => ['MMMDVLII'],
679  3548 => ['MMMDVLIII'],
680  3549 => ['MMMDVLIV', 'MMMDIL'],
681  3595 => ['MMMDVC'],
682  3596 => ['MMMDVCI'],
683  3597 => ['MMMDVCII'],
684  3598 => ['MMMDVCIII'],
685  3599 => ['MMMDVCIV', 'MMMDIC'],
686  3645 => ['MMMDCVL'],
687  3646 => ['MMMDCVLI'],
688  3647 => ['MMMDCVLII'],
689  3648 => ['MMMDCVLIII'],
690  3649 => ['MMMDCVLIV', 'MMMDCIL'],
691  3695 => ['MMMDCVC'],
692  3696 => ['MMMDCVCI'],
693  3697 => ['MMMDCVCII'],
694  3698 => ['MMMDCVCIII'],
695  3699 => ['MMMDCVCIV', 'MMMDCIC'],
696  3745 => ['MMMDCCVL'],
697  3746 => ['MMMDCCVLI'],
698  3747 => ['MMMDCCVLII'],
699  3748 => ['MMMDCCVLIII'],
700  3749 => ['MMMDCCVLIV', 'MMMDCCIL'],
701  3795 => ['MMMDCCVC'],
702  3796 => ['MMMDCCVCI'],
703  3797 => ['MMMDCCVCII'],
704  3798 => ['MMMDCCVCIII'],
705  3799 => ['MMMDCCVCIV', 'MMMDCCIC'],
706  3845 => ['MMMDCCCVL'],
707  3846 => ['MMMDCCCVLI'],
708  3847 => ['MMMDCCCVLII'],
709  3848 => ['MMMDCCCVLIII'],
710  3849 => ['MMMDCCCVLIV', 'MMMDCCCIL'],
711  3895 => ['MMMDCCCVC'],
712  3896 => ['MMMDCCCVCI'],
713  3897 => ['MMMDCCCVCII'],
714  3898 => ['MMMDCCCVCIII'],
715  3899 => ['MMMDCCCVCIV', 'MMMDCCCIC'],
716  3945 => ['MMMCMVL'],
717  3946 => ['MMMCMVLI'],
718  3947 => ['MMMCMVLII'],
719  3948 => ['MMMCMVLIII'],
720  3949 => ['MMMCMVLIV', 'MMMCMIL'],
721  3950 => ['MMMLM'],
722  3951 => ['MMMLMI'],
723  3952 => ['MMMLMII'],
724  3953 => ['MMMLMIII'],
725  3954 => ['MMMLMIV'],
726  3955 => ['MMMLMV'],
727  3956 => ['MMMLMVI'],
728  3957 => ['MMMLMVII'],
729  3958 => ['MMMLMVIII'],
730  3959 => ['MMMLMIX'],
731  3960 => ['MMMLMX'],
732  3961 => ['MMMLMXI'],
733  3962 => ['MMMLMXII'],
734  3963 => ['MMMLMXIII'],
735  3964 => ['MMMLMXIV'],
736  3965 => ['MMMLMXV'],
737  3966 => ['MMMLMXVI'],
738  3967 => ['MMMLMXVII'],
739  3968 => ['MMMLMXVIII'],
740  3969 => ['MMMLMXIX'],
741  3970 => ['MMMLMXX'],
742  3971 => ['MMMLMXXI'],
743  3972 => ['MMMLMXXII'],
744  3973 => ['MMMLMXXIII'],
745  3974 => ['MMMLMXXIV'],
746  3975 => ['MMMLMXXV'],
747  3976 => ['MMMLMXXVI'],
748  3977 => ['MMMLMXXVII'],
749  3978 => ['MMMLMXXVIII'],
750  3979 => ['MMMLMXXIX'],
751  3980 => ['MMMLMXXX'],
752  3981 => ['MMMLMXXXI'],
753  3982 => ['MMMLMXXXII'],
754  3983 => ['MMMLMXXXIII'],
755  3984 => ['MMMLMXXXIV'],
756  3985 => ['MMMLMXXXV'],
757  3986 => ['MMMLMXXXVI'],
758  3987 => ['MMMLMXXXVII'],
759  3988 => ['MMMLMXXXVIII'],
760  3989 => ['MMMLMXXXIX'],
761  3990 => ['MMMLMXL', 'MMMXM'],
762  3991 => ['MMMLMXLI', 'MMMXMI'],
763  3992 => ['MMMLMXLII', 'MMMXMII'],
764  3993 => ['MMMLMXLIII', 'MMMXMIII'],
765  3994 => ['MMMLMXLIV', 'MMMXMIV'],
766  3995 => ['MMMLMVL', 'MMMXMV', 'MMMVM'],
767  3996 => ['MMMLMVLI', 'MMMXMVI', 'MMMVMI'],
768  3997 => ['MMMLMVLII', 'MMMXMVII', 'MMMVMII'],
769  3998 => ['MMMLMVLIII', 'MMMXMVIII', 'MMMVMIII'],
770  3999 => ['MMMLMVLIV', 'MMMXMIX', 'MMMVMIV', 'MMMIM'],
771  ];
772 
773  private const THOUSANDS = ['', 'M', 'MM', 'MMM'];
774  private const HUNDREDS = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'];
775  private const TENS = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'];
776  private const ONES = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'];
777  const MAX_ROMAN_VALUE = 3999;
778  const MAX_ROMAN_STYLE = 4;
779 
780  private static function valueOk(int $aValue, int $style): string
781  {
782  $origValue = $aValue;
783  $m = \intdiv($aValue, 1000);
784  $aValue %= 1000;
785  $c = \intdiv($aValue, 100);
786  $aValue %= 100;
787  $t = \intdiv($aValue, 10);
788  $aValue %= 10;
789  $result = self::THOUSANDS[$m] . self::HUNDREDS[$c] . self::TENS[$t] . self::ONES[$aValue];
790  if ($style > 0) {
791  if (array_key_exists($origValue, self::VALUES)) {
792  $arr = self::VALUES[$origValue];
793  $idx = min($style, count($arr)) - 1;
794  $result = $arr[$idx];
795  }
796  }
797 
798  return $result;
799  }
800 
801  private static function styleOk(int $aValue, int $style): string
802  {
803  return ($aValue < 0 || $aValue > self::MAX_ROMAN_VALUE) ? Functions::VALUE() : self::valueOk($aValue, $style);
804  }
805 
806  public static function calculateRoman(int $aValue, int $style): string
807  {
808  return ($style < 0 || $style > self::MAX_ROMAN_STYLE) ? Functions::VALUE() : self::styleOk($aValue, $style);
809  }
810 
821  public static function evaluate($aValue, $style = 0)
822  {
823  try {
824  $aValue = Helpers::validateNumericNullBool($aValue);
825  if (is_bool($style)) {
826  $style = $style ? 0 : 4;
827  }
829  } catch (Exception $e) {
830  return $e->getMessage();
831  }
832 
833  return self::calculateRoman((int) $aValue, (int) $style);
834  }
835 }
static validateNumericNullBool($number)
Many functions accept null/false/true argument treated as 0/0/1.
Definition: Helpers.php:27
static calculateRoman(int $aValue, int $style)
Definition: Roman.php:806
$style
Definition: example_012.php:70
$result
static validateNumericNullSubstitution($number, $substitute)
Validate numeric, but allow substitute for null.
Definition: Helpers.php:51
static styleOk(int $aValue, int $style)
Definition: Roman.php:801
static evaluate($aValue, $style=0)
ROMAN.
Definition: Roman.php:821
static valueOk(int $aValue, int $style)
Definition: Roman.php:780