/**
  * Creates a currency from its JSON resource.
  *
  * @param string $json
  *
  * @return \Commercie\Currency\CurrencyInterface
  */
 protected function createCurrencyFromJson($json)
 {
     $currency_data = json_decode($json);
     $currency = new Currency();
     $currency->setCurrencyCode($currency_data->ISO4217Code);
     if (isset($currency_data->ISO4217Number)) {
         $currency->setCurrencyNumber($currency_data->ISO4217Number);
     }
     if (isset($currency_data->alternativeSigns)) {
         $currency->setAlternativeSigns($currency_data->alternativeSigns);
     }
     $currency->setLabel($currency_data->title);
     if (isset($currency_data->roundingStep)) {
         $currency->setRoundingStep($currency_data->roundingStep);
     }
     if (isset($currency_data->sign)) {
         $currency->setSign($currency_data->sign);
     }
     if (isset($currency_data->subunits)) {
         $currency->setSubunits($currency_data->subunits);
     }
     $usages_data = $currency_data->usage;
     $usages = [];
     foreach ($currency_data as $property => $value) {
         $this->{$property} = $value;
     }
     foreach ($usages_data as $usage_data) {
         $usage = new Usage();
         if (isset($usage_data->ISO8601From)) {
             $usage->setStart($usage_data->ISO8601From);
         }
         if (isset($usage_data->ISO8601To)) {
             $usage->setEnd($usage_data->ISO8601To);
         }
         if (isset($usage_data->ISO3166Code)) {
             $usage->setCountryCode($usage_data->ISO3166Code);
         }
         $usages[] = $usage;
     }
     $currency->setUsages($usages);
     return $currency;
 }
Example #2
0
 protected function init()
 {
     parent::init();
     $this->getGraphBuilder()->setCallMode();
 }
Example #3
0
require_once 'includes/scaffolding.php';
require_once 'includes/i18n.php';
require_once 'includes/usage.php';
require_once 'includes/iconstack.php';
require_once 'includes/functions.php';
require_once 'includes/iconoverview.php';
require_once 'includes/iconstyler.php';
require_once 'includes/iconjs.php';
require_once 'includes/iconsprite.php';
// 1. Parsing of command line arguments and basic program feedback
// ---------------------------------------------------------------------------
// Load the default settings.
Settings::load_settings_file('includes/defaults.php');
// Parse the user's command line arguments and determine whether the user
// is in need of seeing the usage guide.
$usage = new Usage();
$cl_settings = $usage->get_user_settings();
// Check the current revision number for user feedback and for
// inclusion in the output files.
$revision = trim(shell_exec('git rev-list HEAD --count 2> /dev/null'));
$revision = $revision ? 'r' . $revision : '[unknown]';
$cl_settings['revision'] = $revision;
if ($usage->needs_usage) {
    // Display usage and exit.
    $usage->load_tpl_file(Settings::get('resources_dir') . Settings::get('usage_tpl'));
    $usage->display_usage();
    exit;
}
// Merge the user's command line arguments into the settings.
Settings::load_settings($cl_settings);
// Export the settings variables so that we can use them here.