<commit_before><?php

namespace Bartlett\Reflect\Api\V3;

use Bartlett\Reflect\Model;

class Reflection extends Common
{
    const FORMAT_TEXT = 'text';

    public function __call($name, $args)
    {
        if ('invoke' == $name) {
        } elseif ('class' == $name) {
            list($argument, $source, $alias, $return) = $args;
            return $this->class_($argument, $source, $alias, $return);

        } elseif ('function' == $name) {
            list($argument, $source, $alias, $return) = $args;
            return $this->function_($argument, $source, $alias, $return);
        }
    }

    public function __invoke($arg)
    {
    }

    public function class_($argument, $source, $alias = null, $return = false)
    {
        $api = new Analyser();
        $metrics = $api->run($source, array('reflection'), $alias);

        $collect = $metrics['ReflectionAnalyser']->filter(
            function($element) use ($argument) {
                return $element instanceof Model\ClassModel
                    && $element->getName() === $argument;
            }
        );

        if (count($collect) === 0) {
            throw new \Exception(
                sprintf('Class "%s" not found.', $argument)
            );
        }
        return $collect->first();
    }

    public function function_($argument, $source, $alias = null, $return = false)
    {
        $api = new Analyser();
        $metrics = $api->run($source, array('reflection'), $alias);

        $collect = $metrics['ReflectionAnalyser']->filter(
            function($element) use ($argument) {
                return $element instanceof Model\FunctionModel
                    && $element->getName() === $argument;
            }
        );

        if (count($collect) === 0) {
            throw new \Exception(<commit_msg>event dispatcher is not propagated to analyser sub-process<commit_after><?php

namespace Bartlett\Reflect\Api\V3;

use Bartlett\Reflect\Model;

class Reflection extends Common
{
    const FORMAT_TEXT = 'text';

    public function __call($name, $args)
    {
        if ('invoke' == $name) {
        } elseif ('class' == $name) {
            list($argument, $source, $alias, $return) = $args;
            return $this->class_($argument, $source, $alias, $return);

        } elseif ('function' == $name) {
            list($argument, $source, $alias, $return) = $args;
            return $this->function_($argument, $source, $alias, $return);
        }
    }

    public function __invoke($arg)
    {
    }

    public function class_($argument, $source, $alias = null, $return = false)
    {
        $api = new Analyser();
        $api->setEventDispatcher($this->eventDispatcher);
        $metrics = $api->run($source, array('reflection'), $alias);

        $collect = $metrics['ReflectionAnalyser']->filter(
            function($element) use ($argument) {
                return $element instanceof Model\ClassModel
                    && $element->getName() === $argument;
            }
        );

        if (count($collect) === 0) {
            throw new \Exception(
                sprintf('Class "%s" not found.', $argument)
            );
        }
        return $collect->first();
    }

    public function function_($argument, $source, $alias = null, $return = false)
    {
        $api = new Analyser();
        $api->setEventDispatcher($this->eventDispatcher);
        $metrics = $api->run($source, array('reflection'), $alias);

        $collect = $metrics['ReflectionAnalyser']->filter(
            function($element) use ($argument) {
                return $element instanceof Model\FunctionModel
                    && $element->getName() === $argument;
            }
        );

        if (count($collect) === 0) {
            throw new \Exception(
{'fraction_non_alphanumeric': 0.1542736173590897, 'fraction_numerical': 0.0015877216194760519, 'mean_word_length': 2.1162407254740314, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '5096701', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1030, 'n_words': 246}