<commit_before><?php

namespace disclosure;

trait Injector
{
    private function inject()
    {
        $args = func_get_args();
        if (is_callable(end($args))) {
            $callback = array_pop($args);
        }
        $deps = [];
        $missing = false;
        foreach ($args as $arg) {
            try {
                $deps[$arg] = call_user_func(Container::get($arg));
            } catch (UnregisteredException $e) {
                $missing = true;
                $deps[$arg] = null;
            }
        }
        if (isset($callback)) {
            $deps = call_user_func_array($callback, $deps);
        }
        foreach ($deps as $name => $value) {
            if (isset($value)) {
                $this->$name = $value;
            }
        }
        if ($missing) {
            throw new UnregisteredException;
        }
    }

    private function injectAs()
    {
    }
}<commit_msg>implement injectAs<commit_after><?php

namespace disclosure;

trait Injector
{
    private function inject()
    {
        $args = func_get_args();
        if (is_callable(end($args))) {
            $callback = array_pop($args);
        }
        $deps = [];
        $missing = false;
        foreach ($args as $arg) {
            try {
                $deps[$arg] = call_user_func(Container::get($arg));
            } catch (UnregisteredException $e) {
                $missing = true;
                $deps[$arg] = null;
            }
        }
        if (isset($callback)) {
            $deps = call_user_func_array($callback, $deps);
        }
        foreach ($deps as $name => $value) {
            if (isset($value)) {
                $this->$name = $value;
            }
        }
        if ($missing) {
            throw new UnregisteredException;
        }
    }

    private function injectAs()
    {
        $names = func_get_args();
        return function() use($names) {
            $stuff = func_get_args();
            $return = [];
            foreach ($names as $key => $value) {
                $return[$value] = $stuff[$key];
            }
            return $return;
        };
    }
}
{'fraction_non_alphanumeric': 0.13647058823529412, 'fraction_numerical': 0.0, 'mean_word_length': 1.407701019252548, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '1295180', 'n_tokens_mistral': 624, 'n_tokens_neox': 608, 'n_words': 124}