<commit_before><?php
/**
 * @author <NAME> <<EMAIL>>
 * @copyright 2009-2014 Vanilla Forums Inc.
 * @license MIT
 */

namespace Garden\Cli;

/**
 * This class represents the parsed and validated argument list.
 */
class Args implements \JsonSerializable, \ArrayAccess {
    protected $command;
    protected $opts;
    protected $args;
    protected $meta;

    /**
     * Initialize the {@link Args} instance.
     *
     * @param string $command The name of the command.
     * @param array $opts An array of command line options.
     * @param array $args A numeric array of command line args.
     */
    public function __construct($command = '', $opts = [], $args = []) {
        $this->command = $command;
        $this->opts = $opts;
        $this->args = $args;
        $this->meta = [];
    }

    /**
     * Add an argument to the args array.
     *
     * @param string $value The argument to add.
     * @param string? $index The index to add the arg at.
     * @return Args Returns $this for fluent calls.
     */
    public function addArg($value, $index = null) {
        if ($index !== null) {
            $this->args[$index] = $value;
        } else {
            $this->args[] = $value;
        }
        return $this;
    }

    /**
     * Get an argument at a given index.
     *
     * Arguments can be accessed by name or index.
     *
     * @param string|int $index
     * @param mixed $default The default value to return if the argument is not found.
     * @return mixed Returns the argument at {@link $index} or {@link $default}.
     */
    public function getArg($index, $default = null) {
        if (array_key_exists($index, $this->args)) {
            return $this->args[$index];
        } elseif (is_int($index)) {
            $values = array_values($this->args);
            if (array_key_exists($index, $values)) {
                return $values[$index];<commit_msg>Change the @param type to string|null<commit_after><?php
/**
 * @author <NAME> <<EMAIL>>
 * @copyright 2009-2014 Vanilla Forums Inc.
 * @license MIT
 */

namespace Garden\Cli;

/**
 * This class represents the parsed and validated argument list.
 */
class Args implements \JsonSerializable, \ArrayAccess {
    protected $command;
    protected $opts;
    protected $args;
    protected $meta;

    /**
     * Initialize the {@link Args} instance.
     *
     * @param string $command The name of the command.
     * @param array $opts An array of command line options.
     * @param array $args A numeric array of command line args.
     */
    public function __construct($command = '', $opts = [], $args = []) {
        $this->command = $command;
        $this->opts = $opts;
        $this->args = $args;
        $this->meta = [];
    }

    /**
     * Add an argument to the args array.
     *
     * @param string $value The argument to add.
     * @param string|null $index The index to add the arg at.
     * @return Args Returns $this for fluent calls.
     */
    public function addArg($value, $index = null) {
        if ($index !== null) {
            $this->args[$index] = $value;
        } else {
            $this->args[] = $value;
        }
        return $this;
    }

    /**
     * Get an argument at a given index.
     *
     * Arguments can be accessed by name or index.
     *
     * @param string|int $index
     * @param mixed $default The default value to return if the argument is not found.
     * @return mixed Returns the argument at {@link $index} or {@link $default}.
     */
    public function getArg($index, $default = null) {
        if (array_key_exists($index, $this->args)) {
            return $this->args[$index];
        } elseif (is_int($index)) {
            $values = array_values($this->args);
            if (array_key_exists($index, $values)) {
                return $values[$index];
{'fraction_non_alphanumeric': 0.13145539906103287, 'fraction_numerical': 0.004173187271778821, 'mean_word_length': 2.1799336650082917, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '7096593', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1093, 'n_words': 378}