<commit_before><?php
namespace LazyRecord;
use Exception;
use RuntimeException;
use ReflectionClass;
use LazyRecord\Inflector;
use LazyRecord\Schema\DynamicSchemaDeclare;

class ClassUtils
{
    static public function get_declared_schema_classes() 
    {
        $classes = get_declared_classes();
        return self::filter_schema_classes($classes);
    }

    /**
     * Get referenced schema classes and put them in order.
     *
     * @param array schema objects
     */
    static public function expand_schema_classes($classes)
    {
        $schemas = array();
        foreach( $classes as $class ) {
            $schema = new $class; // declare schema
            $refs = $schema->getReferenceSchemas();
            foreach ( $refs as $refClass => $v ) {
                $schemas[] = $refClass;
            }
            $schemas[] = $class;
        }
        $schemaClasses = array_unique($schemas);
        return self::schema_classes_to_objects($schemaClasses);
    }


    public static function schema_classes_to_objects($classes) {
        $schemas = array();
        foreach( $classes as $class ) {
            if( is_a($class,'LazyRecord\BaseModel',true) ) {
                // TODO: refactor this to a factory method
                $model = new $class;
                $schemas[] = new \LazyRecord\Schema\DynamicSchemaDeclare($model);
            }
            elseif( is_subclass_of($class,'LazyRecord\Schema\SchemaDeclare',true) ) {
                $schemas[] = new $class; 
            }
        }
        return $schemas;
    }

    /**
     * Filter non-dynamic schema declare classes.
     *
     * @param array $classes class list.
     */
    static public function filter_schema_classes($classes)
    {
        $list = array();
        foreach( $classes as $class ) {
            // skip abstract classes.
            if (
              ! is_subclass_of($class, 'LazyRecord\Schema\SchemaDeclare',true)
              || is_a($class, 'LazyRecord\Schema\DynamicSchemaDeclare',true)<commit_msg>update doc block<commit_after><?php
namespace LazyRecord;
use Exception;
use RuntimeException;
use ReflectionClass;
use LazyRecord\Inflector;
use LazyRecord\Schema\DynamicSchemaDeclare;

class ClassUtils
{
    static public function get_declared_schema_classes() 
    {
        $classes = get_declared_classes();
        return self::filter_schema_classes($classes);
    }

    /**
     * Get referenced schema classes and put them in order.
     *
     * @param string[] schema objects
     */
    static public function expand_schema_classes($classes)
    {
        $schemas = array();
        foreach( $classes as $class ) {
            $schema = new $class; // declare schema
            $refs = $schema->getReferenceSchemas();
            foreach ( $refs as $refClass => $v ) {
                $schemas[] = $refClass;
            }
            $schemas[] = $class;
        }
        $schemaClasses = array_unique($schemas);
        return self::schema_classes_to_objects($schemaClasses);
    }


    public static function schema_classes_to_objects($classes) {
        $schemas = array();
        foreach( $classes as $class ) {
            if( is_a($class,'LazyRecord\BaseModel',true) ) {
                // TODO: refactor this to a factory method
                $model = new $class;
                $schemas[] = new \LazyRecord\Schema\DynamicSchemaDeclare($model);
            }
            elseif( is_subclass_of($class,'LazyRecord\Schema\SchemaDeclare',true) ) {
                $schemas[] = new $class; 
            }
        }
        return $schemas;
    }

    /**
     * Filter non-dynamic schema declare classes.
     *
     * @param string[] $classes class list.
     */
    static public function filter_schema_classes($classes)
    {
        $list = array();
        foreach( $classes as $class ) {
            // skip abstract classes.
            if (
              ! is_subclass_of($class, 'LazyRecord\Schema\SchemaDeclare',true)
              || is_a($class, 'LazyRecord\Schema\DynamicSchemaDeclare',true)
{'fraction_non_alphanumeric': 0.11069928341981715, 'fraction_numerical': 0.0, 'mean_word_length': 2.1162432640492685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '494261', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1089, 'n_words': 253}