<commit_before><?php

namespace Ornament;

use ReflectionClass;
use ReflectionMethod;
use ReflectionProperty;

abstract class Repository
{
    private static $adapters = [];
    private static $reflected = [];

    public static function registerAdapter($obj, $adapter, $id, array $fields)
    {
        $key = spl_object_hash($obj);
        if (!isset(self::$adapters[$key])) {
            self::$adapters[$key] = [];
        }
        $adapter_key = spl_object_hash($adapter)."#$id";
        $model = new Model($adapter);
        $new = true;
        foreach ($fields as $field) {
            if (isset($obj->$field)) {
                $new = false;
            }
            $model->$field =& $obj->$field;
        }
        if ($new) {
            $model->markNew();
        } else {
            $model->markClean();
        }
        self::$adapters[$key][$adapter_key] = $model;
    }

    public static function getAdapters($obj)
    {
        $key = spl_object_hash($obj);
        if (!isset(self::$adapters[$key])) {
            throw new NoAdaptersRegisteredException($obj);
        }
        return self::$adapters[$key];
    }

    private static function getModelValues($obj)
    {
        $properties = self::getProperties($obj);
        $data = [];
        foreach ($properties as $prop) {
            $data[$prop] = $obj->$prop;
        }
        return $data;
    }

    public static function getProperties($obj)
    {
        $class = get_class($obj);
        if (!isset(self::$reflected[$class])) {
            $reflected = new ReflectionClass($obj);
            self::$reflected[$class] = [];
            foreach ($reflected->getProperties(
                ReflectionProperty::IS_PUBLIC
            ) as $prop) {
                self::$reflected[$class][] = $prop->getName();
            }
            foreach ($reflected->getMethods(
                ReflectionMethod::IS_PUBLIC
            ) as $method) {
                if (preg_match('@^[gs]et@', $method->getName())) {
                    self::$reflected[$class][] = Helper::normalize(preg_replace(<commit_msg>ignore static properties<commit_after><?php

namespace Ornament;

use ReflectionClass;
use ReflectionMethod;
use ReflectionProperty;

abstract class Repository
{
    private static $adapters = [];
    private static $reflected = [];

    public static function registerAdapter($obj, $adapter, $id, array $fields)
    {
        $key = spl_object_hash($obj);
        if (!isset(self::$adapters[$key])) {
            self::$adapters[$key] = [];
        }
        $adapter_key = spl_object_hash($adapter)."#$id";
        $model = new Model($adapter);
        $new = true;
        foreach ($fields as $field) {
            if (isset($obj->$field)) {
                $new = false;
            }
            $model->$field =& $obj->$field;
        }
        if ($new) {
            $model->markNew();
        } else {
            $model->markClean();
        }
        self::$adapters[$key][$adapter_key] = $model;
    }

    public static function getAdapters($obj)
    {
        $key = spl_object_hash($obj);
        if (!isset(self::$adapters[$key])) {
            throw new NoAdaptersRegisteredException($obj);
        }
        return self::$adapters[$key];
    }

    private static function getModelValues($obj)
    {
        $properties = self::getProperties($obj);
        $data = [];
        foreach ($properties as $prop) {
            $data[$prop] = $obj->$prop;
        }
        return $data;
    }

    public static function getProperties($obj)
    {
        $class = get_class($obj);
        if (!isset(self::$reflected[$class])) {
            $reflected = new ReflectionClass($obj);
            self::$reflected[$class] = [];
            foreach ($reflected->getProperties(
                ReflectionProperty::IS_PUBLIC
            ) as $prop) {
                if ($prop->isStatic()) {
                    continue;
                }
                self::$reflected[$class][] = $prop->getName();
            }
            foreach ($reflected->getMethods(
                ReflectionMethod::IS_PUBLIC
            ) as $method) {
                if (preg_match('@^[gs]et@', $method->getName())) {
                    self::$reflected[$class][] = Helper::normalize(preg_replace(
{'fraction_non_alphanumeric': 0.15161441272812354, 'fraction_numerical': 0.0, 'mean_word_length': 1.9341111873713108, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '2052198', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1194, 'n_words': 228}