1. Go to this page and download the library: Download wandersonwhcr/romans library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wandersonwhcr / romans example snippets
use Romans\Filter\RomanToInt;
$filter = new RomanToInt();
$result = $filter->filter('MCMXCIX'); // 1999
use Romans\Filter\IntToRoman;
$filter = new IntToRoman();
$result = $filter->filter(1999); // MCMXCIX
use Romans\Filter\RomanToInt;
use Romans\Lexer\Exception as LexerException;
use Romans\Parser\Exception as ParserException;
$filter = new RomanToInt();
try {
$filter->filter($input);
} catch (LexerException $e) {
// Unknown Token (LexerException::UNKNOWN_TOKEN)
} catch (ParserException $e) {
// Invalid Token Type (Not String) (ParserException::INVALID_TOKEN_TYPE)
// Unknown Token (ParserException::UNKNOWN_TOKEN)
// Invalid Roman (ParserException::INVALID_ROMAN)
}
use Romans\Filter\IntToRoman;
use Romans\Filter\Exception as FilterException;
$filter = new IntToRoman();
try {
$filter->filter($input);
} catch (FilterException $e) {
// Invalid Integer (< 0) (FilterException::INVALID_INTEGER)
}
use Romans\Filter\RomanToInt;
use Romans\Filter\IntToRoman;
$filter = new RomanToInt();
$result = $filter->filter('N'); // 0 (Zero)
$filter = new IntToRoman();
$result = $filter->filter(0); // N
use Romans\Filter\IntToRoman;
use Romans\Filter\RomanToInt;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
$cache = new ArrayAdapter();
$filter = new RomanToInt();
$filter->setCache($cache);
$result = $filter->filter('MCMXCIX'); // 1999
$result = $filter->filter('MCMXCIX'); // 1999 (from cache)
$filter = new IntToRoman();
$filter->setCache($cache);
$result = $filter->filter(1999); // MCMXCIX
$result = $filter->filter(1999); // MCMXCIX (from cache)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.