You are here

public function Currency::resourceParse in Currency 7.2

Parses a YAML file into this object.

Parameters

string $yaml:

1 call to Currency::resourceParse()
Currency::resourceLoad in currency/vendor/bartfeenstra/currency/src/BartFeenstra/Currency/Currency.php
Loads a currency resource into this object.

File

currency/vendor/bartfeenstra/currency/src/BartFeenstra/Currency/Currency.php, line 134
Contains class \BartFeenstra\Currency\Currency.

Class

Currency
Describes a currency.

Namespace

BartFeenstra\Currency

Code

public function resourceParse($yaml) {
  $currency_data = Yaml::parse($yaml);
  $usages_data = $currency_data['usage'];
  $currency_data['usage'] = array();
  foreach ($currency_data as $property => $value) {
    $this->{$property} = $value;
  }
  foreach ($usages_data as $usage_data) {
    $usage = new Usage();
    foreach ($usage_data as $property => $value) {
      $usage->{$property} = $value;
    }
    $this->usage[] = $usage;
  }
  unset($currency_data);
}