<commit_before><?php

namespace Inspector;

use Inspector\Inspection\InspectionInterface;

use ReflectionClass;

class Inspector implements InspectorInterface
{
    private $inspections = array();
    private $container;
    
    public function __construct($container)
    {
        $this->container = $container;
    }
    
    public function addInspection(InspectionInterface $inspection)
    {
        $this->inspections[] = $inspection;
    }
    public function getInspections()
    {
        return $this->inspections;
    }
    
    public function runInspection(InspectionInterface $inspection)
    {
        $className = $inspection->getClassName();
        $methodName = $inspection->getMethodName();
        
        $reflector = new ReflectionClass($className);
        $method = $reflector->getConstructor();
        $arguments = array();
        
        // Inject requested constructor arguments
        if ($method) {
            foreach ($method->getParameters() as $p) {
                if ($p->getName() == 'db') {
                    $arguments[] = $this->container['db'];
                }
            }
        }
        $instance = $reflector->newInstanceArgs($arguments);
        
        foreach ($reflector->getMethods() as $method) {
            if ($method->getName()==$methodName) {
                if ($method->isPublic()) {
                    $instance->$methodName($inspection);
                }
            }
        }<commit_msg>Support pdo key in container<commit_after><?php

namespace Inspector;

use Inspector\Inspection\InspectionInterface;

use ReflectionClass;

class Inspector implements InspectorInterface
{
    private $inspections = array();
    private $container;
    
    public function __construct($container)
    {
        $this->container = $container;
    }
    
    public function addInspection(InspectionInterface $inspection)
    {
        $this->inspections[] = $inspection;
    }
    public function getInspections()
    {
        return $this->inspections;
    }
    
    public function runInspection(InspectionInterface $inspection)
    {
        $className = $inspection->getClassName();
        $methodName = $inspection->getMethodName();
        
        $reflector = new ReflectionClass($className);
        $method = $reflector->getConstructor();
        $arguments = array();
        
        // Inject requested constructor arguments
        if ($method) {
            foreach ($method->getParameters() as $p) {
                if ($p->getName() == 'db') {
                    $arguments[] = $this->container['db'];
                }
                if ($p->getName() == 'pdo') {
                    $arguments[] = $this->container['pdo'];
                }
            }
        }
        $instance = $reflector->newInstanceArgs($arguments);
        
        foreach ($reflector->getMethods() as $method) {
            if ($method->getName()==$methodName) {
                if ($method->isPublic()) {
                    $instance->$methodName($inspection);
                }
            }
        }
{'fraction_non_alphanumeric': 0.12463390823299707, 'fraction_numerical': 0.0, 'mean_word_length': 1.9671814671814671, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '185552', 'n_tokens_mistral': 812, 'n_tokens_neox': 783, 'n_words': 155}