<commit_before><?php

namespace Admingenerator\GeneratorBundle\Guesser;

use Admingenerator\GeneratorBundle\Exception\NotImplementedException;
use Doctrine\Common\Util\Inflector;
use Symfony\Component\DependencyInjection\ContainerAware;

class PropelORMFieldGuesser extends ContainerAware
{
    /**
     * @var boolean
     */
    private $guessRequired;

    /**
     * @var boolean
     */
    private $defaultRequired;

    /**
     * @var array
     */
    private $cache = array();

    /**
     * @param $class
     * @return mixed
     */
    protected function getMetadatas($class)
    {
        return $this->getTable($class);
    }

    /**
     * @param $class
     * @return array
     */
    public function getAllFields($class)
    {
        $return = array();

        foreach ($this->getMetadatas($class)->getColumns() as $column) {
            $return[] = Inflector::tableize($column->getPhpName());
        }

        return $return;
    }

    /**
     * Find out the database type for given model field path.
     *
     * @param  string $model     The starting model.
     * @param  string $fieldPath The field path.
     * @return string The leaf field's primary key.
     */
    public function getDbType($model, $fieldPath)
    {
        $resolved = $this->resolveRelatedField($model, $fieldPath);
        $class = $resolved['class'];
        $field = $resolved['field'];

        $relation = $this->getRelation($field, $class);

        if ($relation) {
            return \RelationMap::MANY_TO_ONE === $relation->getType() ? 'model' : 'collection';
        }

        $column = $this->getColumn($class, $field);

        return $column ? $column->getType() : 'virtual';
    }

    /**
     * @param $fieldName
     * @param $class
     * @return bool
     */
    protected function getRelation($fieldName, $class)
    {
        $table = $this->getMetadatas($class);
        $relName = Inflector::classify($fieldName);
<commit_msg>Update PropelORMFieldGuesser.php<commit_after><?php

namespace Admingenerator\GeneratorBundle\Guesser;

use Admingenerator\GeneratorBundle\Exception\NotImplementedException;
use Doctrine\Common\Util\Inflector;
use Symfony\Component\DependencyInjection\ContainerAware;

class PropelORMFieldGuesser extends ContainerAware
{
    /**
     * @var boolean
     */
    private $guessRequired;

    /**
     * @var boolean
     */
    private $defaultRequired;

    /**
     * @var array
     */
    private $cache = array();

    /**
     * @param $class
     * @return mixed
     */
    protected function getMetadatas($class)
    {
        return $this->getTable($class);
    }

    /**
     * @param $class
     * @return array
     */
    public function getAllFields($class)
    {
        $return = array();

        foreach ($this->getMetadatas($class)->getColumns() as $column) {
            $return[] = Inflector::tableize($column->getPhpName());
        }

        return $return;
    }

    /**
     * Find out the database type for given model field path.
     *
     * @param  string $model     The starting model.
     * @param  string $fieldPath The field path.
     * @return string The leaf field's primary key.
     */
    public function getDbType($model, $fieldPath)
    {
        $resolved = $this->resolveRelatedField($model, $fieldPath);
        $class = $resolved['class'];
        $field = $resolved['field'];

        $relation = $this->getRelation($field, $class);

        if ($relation) {
            return \RelationMap::MANY_TO_ONE === $relation->getType() ? 'model' : 'collection';
        }

        $column = $this->getColumn($class, $field);

        return $column ? $column->getType() : 'virtual';
    }

    /**
     * @param $fieldName
     * @param $class
     * @return mixed The relation object or false.
     */
    protected function getRelation($fieldName, $class)
    {
        $table = $this->getMetadatas($class);
        $relName = Inflector::classify($fieldName);

{'fraction_non_alphanumeric': 0.13679959616355375, 'fraction_numerical': 0.0, 'mean_word_length': 2.401716738197425, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '2469700', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1157, 'n_words': 252}