<commit_before><?php
/**
 * core42 (www.raum42.at)
 *
 * @link http://www.raum42.at
 * @copyright Copyright (c) 2010-2014 raum42 OG (http://www.raum42.at)
 *
 */

namespace Core42\Db\Metadata\Source;

use Zend\Cache\Storage\StorageInterface;
use Zend\Db\Metadata\Source\AbstractSource;

class CacheSource extends AbstractSource
{
    const CACHE_KEY = 'db_metadata';

    /**
     * Constructor
     *
     * @param AbstractSource $source
     * @param StorageInterface $storage
     */
    public function __construct(AbstractSource $source, StorageInterface $storage)
    {
        if ($storage->hasItem(self::CACHE_KEY)) {
            $source->data = $storage->getItem(self::CACHE_KEY);
        } else {

            $source->loadSchemaData();

            $tableNames = $source->getTableNames($source->defaultSchema);
            foreach($tableNames as $table) {

                $source->loadColumnData($table, $source->defaultSchema);
                $source->loadConstraintData($table, $source->defaultSchema);
                $source->loadConstraintReferences($table, $source->defaultSchema);
            }

            $source->loadConstraintDataKeys($source->defaultSchema);
            $source->loadTriggerData($source->defaultSchema);

            $storage->setItem(self::CACHE_KEY, $source->data);<commit_msg>codestyle fixes<commit_after><?php
/**
 * core42 (www.raum42.at)
 *
 * @link http://www.raum42.at
 * @copyright Copyright (c) 2010-2014 raum42 OG (http://www.raum42.at)
 *
 */

namespace Core42\Db\Metadata\Source;

use Zend\Cache\Storage\StorageInterface;
use Zend\Db\Metadata\Source\AbstractSource;

class CacheSource extends AbstractSource
{
    const CACHE_KEY = 'db_metadata';

    /**
     * Constructor
     *
     * @param AbstractSource $source
     * @param StorageInterface $storage
     */
    public function __construct(AbstractSource $source, StorageInterface $storage)
    {
        if ($storage->hasItem(self::CACHE_KEY)) {
            $source->data = $storage->getItem(self::CACHE_KEY);
        } else {

            $source->loadSchemaData();

            $tableNames = $source->getTableNames($source->defaultSchema);
            foreach ($tableNames as $table) {

                $source->loadColumnData($table, $source->defaultSchema);
                $source->loadConstraintData($table, $source->defaultSchema);
                $source->loadConstraintReferences($table, $source->defaultSchema);
            }

            $source->loadConstraintDataKeys($source->defaultSchema);
            $source->loadTriggerData($source->defaultSchema);

            $storage->setItem(self::CACHE_KEY, $source->data);
{'fraction_non_alphanumeric': 0.1382697393275406, 'fraction_numerical': 0.01511144692104269, 'mean_word_length': 2.87701317715959, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '2393023', 'n_tokens_mistral': 776, 'n_tokens_neox': 728, 'n_words': 119}