Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F1136504
modifier.romanize.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
632 B
Subscribers
None
modifier.romanize.php
View Options
<?php
declare
(
strict_types
=
1
);
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
use
Keruald\OmniTools\Culture\Rome\RomanNumerals
;
/**
* Smarty romanize modifier plugin
*
* Type: modifier<br>
* Name: romanize<br>
* Purpose: prints a number in roman
*/
function
smarty_modifier_romanize
(
mixed
$number
)
:
string
{
if
(!
is_numeric
(
$number
))
{
return
(
string
)
$number
;
}
try
{
return
RomanNumerals
::
fromHinduArabic
((
int
)
$number
);
}
catch
(
InvalidArgumentException
$ex
)
{
// Not a strictly positive integer, don't modify
return
(
string
)
$number
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Jul 10, 10:06 (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23253
Default Alt Text
modifier.romanize.php (632 B)
Attached To
rZED Zed
Event Timeline
Log In to Comment