<commit_before><?php

/**
 * This model manages Shop Currencies
 *
 * @package  Nails
 * @subpackage  module-shop
 * @category    Model
 * @author    Nails Dev Team
 * @link
 */

namespace Nails\Shop\Model;

use Nails\Factory;
use Nails\Common\Model\Base;

class Currency extends Base
{
    protected $oerUrl;
    protected $rates;

    // --------------------------------------------------------------------------

    /**
     * Construct the model, define defaults and load dependencies.
     */
    public function __construct()
    {
        parent::__construct();

        // --------------------------------------------------------------------------

        //  Load required config file
        $this->config->load('shop/currency');

        // --------------------------------------------------------------------------

        //  Defaults
        $this->oerUrl = 'http://openexchangerates.org/api/latest.json';
        $this->rates  = null;
    }

    // --------------------------------------------------------------------------

    /**
     * Get all defined currencies.
     * @return array
     */
    public function getAll()
    {
        return $this->config->item('currency');
    }

    // --------------------------------------------------------------------------

    /**
     * Get all defined currencies as a flat array; the index is the currency's code,
     * the value is the currency's label.
     * @return array
     */
    public function getAllFlat()
    {
        $out      = array();
        $currency = $this->getAll();

        foreach ($currency as $c) {

            $out[$c->code] = $c->label;
        }

        return $out;
    }

    // --------------------------------------------------------------------------

    /**
     * Gets all currencies supported by the shop.
     * @return array
     */
    public function getAllSupported()
    {<commit_msg>Loading config via the Factory<commit_after><?php

/**
 * This model manages Shop Currencies
 *
 * @package  Nails
 * @subpackage  module-shop
 * @category    Model
 * @author    Nails Dev Team
 * @link
 */

namespace Nails\Shop\Model;

use Nails\Factory;

class Currency
{
    use \Nails\Common\Traits\ErrorHandling;

    // --------------------------------------------------------------------------

    protected $oerUrl;
    protected $rates;
    protected $aCurrency;

    // --------------------------------------------------------------------------

    /**
     * Construct the model, define defaults and load dependencies.
     */
    public function __construct()
    {
        //  Load required config file
        $oConfig = Factory::service('Config');
        $oConfig->load('shop/currency');
        $this->aCurrency = $oConfig->item('currency');

        // --------------------------------------------------------------------------

        //  Defaults
        $this->oerUrl = 'http://openexchangerates.org/api/latest.json';
        $this->rates  = null;
    }

    // --------------------------------------------------------------------------

    /**
     * Get all defined currencies.
     * @return array
     */
    public function getAll()
    {
        return $this->aCurrency;
    }

    // --------------------------------------------------------------------------

    /**
     * Get all defined currencies as a flat array; the index is the currency's code,
     * the value is the currency's label.
     * @return array
     */
    public function getAllFlat()
    {
        $out      = array();
        $currency = $this->getAll();

        foreach ($currency as $c) {

            $out[$c->code] = $c->label;
        }

        return $out;
    }

    // --------------------------------------------------------------------------

    /**
     * Gets all currencies supported by the shop.
     * @return array
     */
    public function getAllSupported()
    {
{'fraction_non_alphanumeric': 0.3262210796915167, 'fraction_numerical': 0.0, 'mean_word_length': 0.974124809741248, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6777892', 'n_tokens_mistral': 940, 'n_tokens_neox': 888, 'n_words': 233}