<commit_before><?php

use Shopware\Plugins\VersionCentralTracker\Components\Credentials;
use Shopware\Plugins\VersionCentralTracker\Components\HttpClient;

class Shopware_Plugins_Core_VersionCentralTracker_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    /**
     * @var array
     */
    protected $pluginInfo = array();

    /**
     * @return array
     */
    public function getCapabilities()
    {
        return array(
            'install' => true,
            'enable'  => true,
            'update'  => true,
        );
    }

    /**
     * @return array
     */
    public function getInfo()
    {
        return array(
            'version'     => $this->getVersion(),
            'author'      => $this->getPluginInfo()['author'],
            'label'       => $this->getLabel(),
            'description' => str_replace('%label%', $this->getLabel(),
                file_get_contents(sprintf('%s/plugin.txt', __DIR__))),
            'copyright'   => $this->getPluginInfo()['copyright'],
            'support'     => $this->getPluginInfo()['support'],
            'link'        => $this->getPluginInfo()['link'],
        );
    }

    /**
     * @return array
     */
    protected function getPluginInfo()
    {
        if ($this->pluginInfo === array()) {
            $file = sprintf('%s/plugin.json', __DIR__);

            if ( ! file_exists($file) || ! is_file($file)) {
                throw new \RuntimeException('The plugin has an invalid version file.');
            }

            $this->pluginInfo = json_decode(file_get_contents($file), true);
        }

        return $this->pluginInfo;
    }

    /**
     * @return string
     */
    public function getLabel()
    {
        return (string)$this->getPluginInfo()['label']['de'];
    }

    /**
     * @return string
     */
    public function getVersion()
    {
        return $this->getPluginInfo()['currentVersion'];
    }

    /**
     * @return bool
     */
    public function install()
    {
        return $this->createEvents();
    }

    /**
     * @param string $oldVersion
     *
     * @return bool
     */
    public function update($oldVersion)
    {
        return $this->createEvents($oldVersion);
    }

    /**
     * @return bool
     */
    public function uninstall()
    {
        return true;
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function enable()
    {
        $output = new Symfony\Component\Console\Output\NullOutput();
        $container = $this->Application()->Container();
        $trackerUpdate = new Shopware\Plugins\VersionCentralTracker\Service\TrackerUpdate(
            $output, $container->get('models')
        );
        $trackerUpdate->execute();

        return true;
    }

    public function afterInit()
    {
        $this->get('Loader')->registerNamespace(
            'Shopware\Plugins\VersionCentralTracker',
            $this->Path()
        );
    }

    /**
     * @param null|string $oldVersion
     *
     * @return bool
     */
    private function createEvents($oldVersion = null)
    {
        $versionClosures = array(

            '1.0.0' => function (Shopware_Plugins_Core_VersionCentralTracker_Bootstrap $bootstrap) {
                $bootstrap->addConfigurationForm();

                $bootstrap->subscribeEvent(
                    'Shopware_Console_Add_Command',
                    'onConsoleAddCommand'
                );

                $bootstrap->subscribeEvent(
                    'Shopware_Controllers_Backend_Config::saveFormAction::after',
                    'afterConfigSave'
                );

                $bootstrap->createCronJob(
                    'VersionCentralTrackerUpdate',
                    'VersionCentralTrackerUpdateCron',
                    60 * 60 * 24,
                    true
                );
                $bootstrap->subscribeEvent(
                    'Shopware_CronJob_VersionCentralTrackerUpdateCron',
                    'executeUpdateCron'
                );

                return true;
            },
        );

        foreach ($versionClosures as $version => $versionClosure) {
            if ($oldVersion === null || version_compare($oldVersion, $this->getVersion(), '>')) {
                if ( ! $versionClosure($this)) {
                    return false;
                }<commit_msg>Fix version comparison operator.<commit_after><?php

use Shopware\Plugins\VersionCentralTracker\Components\Credentials;
use Shopware\Plugins\VersionCentralTracker\Components\HttpClient;

class Shopware_Plugins_Core_VersionCentralTracker_Bootstrap extends Shopware_Components_Plugin_Bootstrap
{
    /**
     * @var array
     */
    protected $pluginInfo = array();

    /**
     * @return array
     */
    public function getCapabilities()
    {
        return array(
            'install' => true,
            'enable'  => true,
            'update'  => true,
        );
    }

    /**
     * @return array
     */
    public function getInfo()
    {
        return array(
            'version'     => $this->getVersion(),
            'author'      => $this->getPluginInfo()['author'],
            'label'       => $this->getLabel(),
            'description' => str_replace('%label%', $this->getLabel(),
                file_get_contents(sprintf('%s/plugin.txt', __DIR__))),
            'copyright'   => $this->getPluginInfo()['copyright'],
            'support'     => $this->getPluginInfo()['support'],
            'link'        => $this->getPluginInfo()['link'],
        );
    }

    /**
     * @return array
     */
    protected function getPluginInfo()
    {
        if ($this->pluginInfo === array()) {
            $file = sprintf('%s/plugin.json', __DIR__);

            if ( ! file_exists($file) || ! is_file($file)) {
                throw new \RuntimeException('The plugin has an invalid version file.');
            }

            $this->pluginInfo = json_decode(file_get_contents($file), true);
        }

        return $this->pluginInfo;
    }

    /**
     * @return string
     */
    public function getLabel()
    {
        return (string)$this->getPluginInfo()['label']['de'];
    }

    /**
     * @return string
     */
    public function getVersion()
    {
        return $this->getPluginInfo()['currentVersion'];
    }

    /**
     * @return bool
     */
    public function install()
    {
        return $this->createEvents();
    }

    /**
     * @param string $oldVersion
     *
     * @return bool
     */
    public function update($oldVersion)
    {
        return $this->createEvents($oldVersion);
    }

    /**
     * @return bool
     */
    public function uninstall()
    {
        return true;
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function enable()
    {
        $output = new Symfony\Component\Console\Output\NullOutput();
        $container = $this->Application()->Container();
        $trackerUpdate = new Shopware\Plugins\VersionCentralTracker\Service\TrackerUpdate(
            $output, $container->get('models')
        );
        $trackerUpdate->execute();

        return true;
    }

    public function afterInit()
    {
        $this->get('Loader')->registerNamespace(
            'Shopware\Plugins\VersionCentralTracker',
            $this->Path()
        );
    }

    /**
     * @param null|string $oldVersion
     *
     * @return bool
     */
    private function createEvents($oldVersion = null)
    {
        $versionClosures = array(

            '1.0.0' => function (Shopware_Plugins_Core_VersionCentralTracker_Bootstrap $bootstrap) {
                $bootstrap->addConfigurationForm();

                $bootstrap->subscribeEvent(
                    'Shopware_Console_Add_Command',
                    'onConsoleAddCommand'
                );

                $bootstrap->subscribeEvent(
                    'Shopware_Controllers_Backend_Config::saveFormAction::after',
                    'afterConfigSave'
                );

                $bootstrap->createCronJob(
                    'VersionCentralTrackerUpdate',
                    'VersionCentralTrackerUpdateCron',
                    60 * 60 * 24,
                    true
                );
                $bootstrap->subscribeEvent(
                    'Shopware_CronJob_VersionCentralTrackerUpdateCron',
                    'executeUpdateCron'
                );

                return true;
            },
        );

        foreach ($versionClosures as $version => $versionClosure) {
            if ($oldVersion === null || version_compare($oldVersion, $this->getVersion(), '<')) {
                if ( ! $versionClosure($this)) {
                    return false;
                }
{'fraction_non_alphanumeric': 0.12946582423894312, 'fraction_numerical': 0.002067777139574957, 'mean_word_length': 1.7028873020800994, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 82, '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': '51348', 'n_tokens_mistral': 2361, 'n_tokens_neox': 2253, 'n_words': 385}