<commit_before><?php
/**
 *
 * @author j
 * Date: 12/31/14
 * Time: 12:04 AM
 *
 * File: entityobjectstorage.class.php
 */

namespace chilimatic\lib\database\sql\orm;

class EntityObjectStorage extends \SplObjectStorage implements \JsonSerializable
{

    public function jsonSerialize()
    {
        $this->rewind();
        $arr = [];

        while ($this->valid()) {
            $arr[] = $this->current();
            $this->next();
        }

        return $arr;
    }
}<commit_msg>- new filter options<commit_after><?php
namespace chilimatic\lib\database\sql\orm;

class EntityObjectStorage extends \SplObjectStorage implements \JsonSerializable
{
    /**
     * @var \ReflectionClass
     */
    private $reflection;

    /**
     * keep them cached
     *
     * @var []
     */
    private $columMap;

    /**
     * @param string $columName
     *
     * @return array
     */
    public function getAsArray($columName = null)
    {
        if ($columName) {
            $this->rewind();
            $obj = $this->current();
            if ($obj) {
                if (!$this->reflection) {
                    $this->reflection = new \ReflectionClass($this->current());
                }

                if ($this->columMap === null) {
                    $this->columMap = [];
                    foreach ($this->reflection->getProperties() as $property) {
                        $this->columMap[$property->getName()] = $property;
                    }
                }
            }
        }


        $this->rewind();
        $arr = [];
        while ($this->valid()) {
            if ($columName && !empty($this->columMap[$columName])) {
                $obj = $this->current();
                /**
                 * @var \ReflectionProperty $test
                 */
                $this->columMap[$columName]->setAccessible(true);
                $arr[] = $this->columMap[$columName]->getValue($obj);
            } else {
                $arr[] = $this->current();
            }

            $this->next();
        }

        return $arr;
    }

    public function jsonSerialize()
    {
        return $this->getAsArray();
    }
}
{'fraction_non_alphanumeric': 0.15213358070500926, 'fraction_numerical': 0.00463821892393321, 'mean_word_length': 1.4907621247113163, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '6603852', 'n_tokens_mistral': 628, 'n_tokens_neox': 597, 'n_words': 109}