<commit_before><?php

/*
 * This file is part of the Valit package.
 *
 * @package Valit
 * @author <NAME> <<EMAIL>>
 * @copyright 2016
 * @license MIT
 */

namespace Moccalotto\Valit\Traits;

use Iterator;
use LogicException;
use ReflectionClass;
use ReflectionMethod;

trait ProvideViaReflection
{
    /**
     ]    * Extract all.
     * @param ReflectionMethod $method
     * @return Iterator
     */
    protected function checksFor(ReflectionMethod $method)
    {
        if (strpos($method->getName(), 'check') !== 0) {
            return;
        }

        $doc = $method->getDocComment();

        if (! ($doc && preg_match_all('/@Check\((\[?[a-zA-Z0-9_," ]+\]?)\)/', $doc, $matches))) {
            return;
        }

        $closure = $method->getClosure($this);

        foreach ($matches[1] as $checksString) {
            $jsonResult = json_decode($checksString);

            if ($jsonResult === null && json_last_error() !== JSON_ERROR_NONE) {
                throw new LogicException(sprintf(
                    'Could not parse the check "%s"',
                    $checksString
                ));
            }

            $checkNames = (array) $jsonResult;

            foreach ($checkNames as $checkName) {
                yield $checkName => $closure;
            }
        }
    }

    public function provides()
    {
        $reflector = new ReflectionClass($this);

        $methods = $reflector->getMethods(ReflectionMethod::IS_PUBLIC);

        $provides = [];
<commit_msg>Unused var<commit_after><?php

/*
 * This file is part of the Valit package.
 *
 * @package Valit
 * @author <NAME> <<EMAIL>>
 * @copyright 2016
 * @license MIT
 */

namespace Moccalotto\Valit\Traits;

use Iterator;
use LogicException;
use ReflectionClass;
use ReflectionMethod;

trait ProvideViaReflection
{
    /**
     ]    * Extract all.
     * @param ReflectionMethod $method
     * @return Iterator
     */
    protected function checksFor(ReflectionMethod $method)
    {
        if (strpos($method->getName(), 'check') !== 0) {
            return;
        }

        $doc = $method->getDocComment();

        if (! ($doc && preg_match_all('/@Check\((\[?[a-zA-Z0-9_," ]+\]?)\)/', $doc, $matches))) {
            return;
        }

        $closure = $method->getClosure($this);

        foreach ($matches[1] as $checksString) {
            $jsonResult = json_decode($checksString);

            if ($jsonResult === null && json_last_error() !== JSON_ERROR_NONE) {
                throw new LogicException(sprintf(
                    'Could not parse the check "%s"',
                    $checksString
                ));
            }

            $checkNames = (array) $jsonResult;

            foreach ($checkNames as $checkName) {
                yield $checkName => $closure;
            }
        }
    }

    public function provides()
    {
        $reflector = new ReflectionClass($this);

        $provides = [];

{'fraction_non_alphanumeric': 0.14042263122017723, 'fraction_numerical': 0.0054533060668029995, 'mean_word_length': 1.9556898288016114, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, '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': '7040808', 'n_tokens_mistral': 891, 'n_tokens_neox': 838, 'n_words': 191}