<commit_before><?php

class Liip_Shared_Helper_Data extends Mage_Core_Helper_Abstract
{
    /**
     * Changes a store config and reloads it to reflect the change immediately
     *
     * @param   string  $path   Configuration key
     * @param   string  $value  New value
     * @param   Mage_Core_Model_Website $website
     * @param   Mage_Core_Model_Store   $store
     */
    public function setStoreConfig($path, $value, Mage_Core_Model_Website $website = null, Mage_Core_Model_Store $store = null)
    {
        $parts = explode('/', $path);

        if (count($parts) != 3) {
            throw new InvalidArgumentException('Invalid path `'.$path.'\' for config');
        }

        $groups = array();
        $groups[$parts[1]]['fields'][$parts[2]]['value'] = $value;

        Mage::getModel('adminhtml/config_data')
            ->setSection($parts[0])
            ->setWebsite($website)
            ->setStore($store)
            ->setGroups($groups)
            ->save();

        Mage::getConfig()->reinit();
        Mage::app()->reinitStores();
    }

    public function translateWildcardsToSql($text)
    {
        return strtr($text, array('*' => '%', '?' => '_'));
    }

    /**
     * Formats a date according to the respective locale
     *
     * Acts the same as `Mage::helper('core')->formatDate()` except that we detect
     * the unsupported format "dd.mm.yy" and fix it accordingly.
     *
     * @param   string  The date to format
     * @param   string  The format type (full, short, long, medium)
     * @return  string  The formatted date
     */
    public function formatDate($date, $formatType = Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)
    {
        if (!$date) {
            return $date;
        }

        // when the year only is two digits, strtotime() fails.
        // strtotime('31.3.12') -> returns today's date
        if (preg_match('/^(\d{1,2}\.\d{1,2})\.(\d{2})$/', $date, $matches)) {
            $date = $matches[1].'.20'.$matches[2];
        }

        return Mage::helper('core')->formatDate($date, $formatType);
    }

    /**
     * Check if current date is withingProduct can be ordered.
     *
     * @param   string $from Datetime
     * @param   string $to Datetime
     * @param   string $date Current date or null for now
     * @return true or false
     */
    public function isDateInRange($from = false, $to = false, $date = null)
    {
        if (!$from && !$to) {
            return true;
        }
        if (!$date) {
            $date = Mage::getModel('core/date')->timestamp(time());
        }
        if ($from) {
            $from = strtotime($from);
        }<commit_msg>#RMMPP-157 time() is not needed there<commit_after><?php

class Liip_Shared_Helper_Data extends Mage_Core_Helper_Abstract
{
    /**
     * Changes a store config and reloads it to reflect the change immediately
     *
     * @param   string  $path   Configuration key
     * @param   string  $value  New value
     * @param   Mage_Core_Model_Website $website
     * @param   Mage_Core_Model_Store   $store
     */
    public function setStoreConfig($path, $value, Mage_Core_Model_Website $website = null, Mage_Core_Model_Store $store = null)
    {
        $parts = explode('/', $path);

        if (count($parts) != 3) {
            throw new InvalidArgumentException('Invalid path `'.$path.'\' for config');
        }

        $groups = array();
        $groups[$parts[1]]['fields'][$parts[2]]['value'] = $value;

        Mage::getModel('adminhtml/config_data')
            ->setSection($parts[0])
            ->setWebsite($website)
            ->setStore($store)
            ->setGroups($groups)
            ->save();

        Mage::getConfig()->reinit();
        Mage::app()->reinitStores();
    }

    public function translateWildcardsToSql($text)
    {
        return strtr($text, array('*' => '%', '?' => '_'));
    }

    /**
     * Formats a date according to the respective locale
     *
     * Acts the same as `Mage::helper('core')->formatDate()` except that we detect
     * the unsupported format "dd.mm.yy" and fix it accordingly.
     *
     * @param   string  The date to format
     * @param   string  The format type (full, short, long, medium)
     * @return  string  The formatted date
     */
    public function formatDate($date, $formatType = Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)
    {
        if (!$date) {
            return $date;
        }

        // when the year only is two digits, strtotime() fails.
        // strtotime('31.3.12') -> returns today's date
        if (preg_match('/^(\d{1,2}\.\d{1,2})\.(\d{2})$/', $date, $matches)) {
            $date = $matches[1].'.20'.$matches[2];
        }

        return Mage::helper('core')->formatDate($date, $formatType);
    }

    /**
     * Check if current date is withingProduct can be ordered.
     *
     * @param   string $from Datetime
     * @param   string $to Datetime
     * @param   string $date Current date or null for now
     * @return true or false
     */
    public function isDateInRange($from = false, $to = false, $date = null)
    {
        if (!$from && !$to) {
            return true;
        }
        if (!$date) {
            $date = Mage::getModel('core/date')->timestamp();
        }
        if ($from) {
            $from = strtotime($from);
        }
{'fraction_non_alphanumeric': 0.14591951861602107, 'fraction_numerical': 0.007333584054155698, 'mean_word_length': 2.183123877917415, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '4068469', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1578, 'n_words': 407}