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

namespace Garden\Container;

use Interop\Container\ContainerInterface;

/**
 * An inversion of control container.
 */
class Container implements ContainerInterface {
    private $currentRule;
    private $instances;
    private $rules;
    private $factories;

    /**
     * Construct a new instance of the {@link Container} class.
     */
    public function __construct() {
        $this->rules = ['*' => ['inherit' => true, 'constructorArgs' => null]];
        $this->currentRule = &$this->rules['*'];
        $this->instances = [];
        $this->factories = [];
    }

    /**
     * Normalize a container entry ID.
     *
     * @param string $id The ID to normalize.
     * @return string Returns a normalized ID as a string.
     */
    private function normalizeID($id) {
        return ltrim($id, '\\');
    }

    /**
     * Set the current rule to the default rule.
     *
     * @return $this
     */
    public function defaultRule() {
        $this->currentRule = &$this->rules['*'];
        return $this;
    }

    /**
     * Set the current rule.
     *
     * @param string $id The ID of the rule.
     * @return $this
     */
    public function rule($id) {
        $id = $this->normalizeID($id);

        if (!isset($this->rules[$id])) {
            $this->rules[$id] = [];
        }
        $this->currentRule = &$this->rules[$id];
        return $this;
    }

    /**
     * Get the class name of the current rule.
     *
     * @return string Returns a class name.
     */
    public function getClass() {
        return empty($this->currentRule['class']) ? '' : $this->currentRule['class'];
    }

    /**
     * Set the name of the class for the current rule.
     *
     * @param string $value A valid class name.
     * @return $this
     */
    public function setClass($value) {
        $this->currentRule['class'] = $value;
        return $this;
    }

    /**
     * Get the factory callback for the current rule.
     *
     * @return callable|null Returns the rule's factory or **null** if it has none.
     */
    public function getFactory() {
        return isset($this->currentRule['factory']) ? $this->currentRule['factory'] : null;
    }

    /**
     * Set the factory that will be used to create the instance for the current rule.
     *
     * @param callable $value This callback will be called to create the instance for the rule.
     * @return $this
     */
    public function setFactory(callable $value) {
        $this->currentRule['factory'] = $value;
        return $this;
    }

    /**
     * Whether or not the current rule is shared.
     *
     * @return bool Returns **true** if the rule is shared or **false** otherwise.
     */
    public function isShared() {
        return !empty($this->currentRule['shared']);
    }

    /**
     * Set whether or not the current rule is shared.
     *
     * @param bool $value Whether or not the current rule is shared.
     * @return $this
     */
    public function setShared($value) {
        $this->currentRule['shared'] = $value;
        return $this;
    }

    /**
     * Whether or not the current rule will inherit to subclasses.
     *
     * @return bool Returns **true** if the current rule inherits or **false** otherwise.
     */
    public function getInherit() {
        return !empty($this->currentRule['inherit']);
    }

    /**
     * Set whether or not the current rule extends to subclasses.
     *
     * @param bool $value Pass **true** to have subclasses inherit this rule or **false** otherwise.
     * @return $this
     */
    public function setInherit($value) {
        $this->currentRule['inherit'] = $value;
        return $this;
    }<commit_msg>Tweak the parameter names of the container access methods<commit_after><?php
/**
 * @author <NAME> <<EMAIL>>
 * @copyright 2009-2016 Vanilla Forums Inc.
 * @license MIT
 */

namespace Garden\Container;

use Interop\Container\ContainerInterface;

/**
 * An inversion of control container.
 */
class Container implements ContainerInterface {
    private $currentRule;
    private $instances;
    private $rules;
    private $factories;

    /**
     * Construct a new instance of the {@link Container} class.
     */
    public function __construct() {
        $this->rules = ['*' => ['inherit' => true, 'constructorArgs' => null]];
        $this->currentRule = &$this->rules['*'];
        $this->instances = [];
        $this->factories = [];
    }

    /**
     * Normalize a container entry ID.
     *
     * @param string $id The ID to normalize.
     * @return string Returns a normalized ID as a string.
     */
    private function normalizeID($id) {
        return ltrim($id, '\\');
    }

    /**
     * Set the current rule to the default rule.
     *
     * @return $this
     */
    public function defaultRule() {
        return $this->rule('*');
    }

    /**
     * Set the current rule.
     *
     * @param string $id The ID of the rule.
     * @return $this
     */
    public function rule($id) {
        $id = $this->normalizeID($id);

        if (!isset($this->rules[$id])) {
            $this->rules[$id] = [];
        }
        $this->currentRule = &$this->rules[$id];
        return $this;
    }

    /**
     * Get the class name of the current rule.
     *
     * @return string Returns a class name.
     */
    public function getClass() {
        return empty($this->currentRule['class']) ? '' : $this->currentRule['class'];
    }

    /**
     * Set the name of the class for the current rule.
     *
     * @param string $className A valid class name.
     * @return $this
     */
    public function setClass($className) {
        $this->currentRule['class'] = $className;
     * @return $this
     */
        return $this;
    }

    /**
     * Get the factory callback for the current rule.
     *
     * @return callable|null Returns the rule's factory or **null** if it has none.
     */
    public function getFactory() {
        return isset($this->currentRule['factory']) ? $this->currentRule['factory'] : null;
    }

    /**
     * Set the factory that will be used to create the instance for the current rule.
     *
     * @param callable $factory This callback will be called to create the instance for the rule.
     * @return $this
     */
    public function setFactory(callable $factory) {
        $this->currentRule['factory'] = $factory;
        return $this;
    }

    /**
     * Whether or not the current rule is shared.
     *
     * @return bool Returns **true** if the rule is shared or **false** otherwise.
     */
    public function isShared() {
        return !empty($this->currentRule['shared']);
    }

    /**
     * Set whether or not the current rule is shared.
     *
     * @param bool $shared Whether or not the current rule is shared.
     * @return $this
     */
    public function setShared($shared) {
        $this->currentRule['shared'] = $shared;
        return $this;
    }

    /**
     * Whether or not the current rule will inherit to subclasses.
     *
     * @return bool Returns **true** if the current rule inherits or **false** otherwise.
     */
    public function getInherit() {
        return !empty($this->currentRule['inherit']);
    }

    /**
     * Set whether or not the current rule extends to subclasses.
     *
     * @param bool $inherit Pass **true** to have subclasses inherit this rule or **false** otherwise.
     * @return $this
     */
    public function setInherit($inherit) {
        $this->currentRule['inherit'] = $inherit;
        return $this;
    }
{'fraction_non_alphanumeric': 0.1344998694176025, 'fraction_numerical': 0.0020893183598850876, 'mean_word_length': 2.1780082987551865, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 58, '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': '2310522', 'n_tokens_mistral': 2184, 'n_tokens_neox': 2131, 'n_words': 706}