<commit_before><?php
namespace Liip\RMT\Action;

use Liip\RMT\Context;
use Liip\RMT\Action\BaseAction;
use Liip\RMT\Exception;
use Liip\RMT\Config\Exception as ConfigException;

/**
 * An updater that updates the version information stored in a class.
 *
 * Typically this would be a class defining a constant for client code to check
 * the version of the library they are using.
 *
 * An example Version class might look like this:
 *
 * class Version
 * {
 *     const VERSION = '1.0.0-beta-4';
 * }
 *
 * @author <NAME> <<EMAIL>>
 */
class UpdateVersionClassAction extends BaseAction
{
    private $options;

    public function __construct($options)
    {
        if (!isset($options['class'])) {
            throw new ConfigException('You must specify the class to update');
        }
        $this->options = $options;
    }

    public function execute()
    {
        $current = Context::getParam('current-version');
        $next = Context::getParam('new-version');
        $versionClass = new \ReflectionClass($this->options['class']);
        $content = file_get_contents($versionClass->getFileName());
        if (false === strpos($content, $current)) {
            throw new Exception('The version class ' . $versionClass->getFileName() . " does not contain the current version $current");
        }
        if (isset($this->options['pattern'])) {
            $current = str_replace('%version%', $current, $this->options['pattern']);
            $next = str_replace('%version%', $next, $this->options['pattern']);
        }
        $content = str_replace($current, $next, $content);
        file_put_contents($versionClass->getFileName(), $content);
    }
}<commit_msg>BaseAction has a protected options field<commit_after><?php
namespace Liip\RMT\Action;

use Liip\RMT\Context;
use Liip\RMT\Action\BaseAction;
use Liip\RMT\Exception;
use Liip\RMT\Config\Exception as ConfigException;

/**
 * An updater that updates the version information stored in a class.
 *
 * Typically this would be a class defining a constant for client code to check
 * the version of the library they are using.
 *
 * An example Version class might look like this:
 *
 * class Version
 * {
 *     const VERSION = '1.0.0-beta-4';
 * }
 *
 * @author <NAME> <<EMAIL>>
 */
class UpdateVersionClassAction extends BaseAction
{
    public function __construct($options)
    {
        if (!isset($options['class'])) {
            throw new ConfigException('You must specify the class to update');
        }
        parent::__construct($options);
    }

    public function execute()
    {
        $current = Context::getParam('current-version');
        $next = Context::getParam('new-version');
        $versionClass = new \ReflectionClass($this->options['class']);
        $content = file_get_contents($versionClass->getFileName());
        if (false === strpos($content, $current)) {
            throw new Exception('The version class ' . $versionClass->getFileName() . " does not contain the current version $current");
        }
        if (isset($this->options['pattern'])) {
            $current = str_replace('%version%', $current, $this->options['pattern']);
            $next = str_replace('%version%', $next, $this->options['pattern']);
        }
        $content = str_replace($current, $next, $content);
        file_put_contents($versionClass->getFileName(), $content);
    }
}
{'fraction_non_alphanumeric': 0.13989330171902786, 'fraction_numerical': 0.0023710729104919974, 'mean_word_length': 3.176980198019802, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 24, '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': '6979929', 'n_tokens_mistral': 931, 'n_tokens_neox': 928, 'n_words': 260}