<commit_before><?php

namespace Gloomy\PagerBundle\Pager;

class Field
{
    public static $defaultDateFormat = 'Y-m-d H:i:s';

    protected $_property;

    protected $_qualifier;

    protected $_type;

    protected $_label;

    protected $_options;

    protected $_dateFormat;

    protected $_visible;

    public function __construct($property, $type = 'text', $label = '', $qualifier = null, $options = array())
    {
        $this->_property  = $property;
        $this->_type      = $type;
        $this->_label     = $label ?: ucfirst($property);
        $this->_qualifier = $qualifier ?: $property;
        $this->_options   = $options;
        $this->_visible   = true;
    }

    public function getProperty()
    {
        return $this->_property;
    }

    public function getQualifier()
    {
        return $this->_qualifier;
    }

    public function setType($type)
    {
        $this->_type = $type;
        return $this;
    }

    public function getType()
    {
        return $this->_type;
    }

    public function setLabel($label)
    {
        $this->_label = $label;
        return $this;
    }

    public function getLabel()
    {
        return $this->_label;
    }

    public function setOptions($options)
    {
        $this->_options = $options;
        return $this;
    }

    public function getOptions()
    {
        return $this->_options;
    }

    public function setDateFormat($dateFormat)
    {
        $this->_dateFormat = $dateFormat;
        return $this;
    }

    public function getDateFormat()
    {
        if (is_null($this->_dateFormat)) {
            $this->_dateFormat = self::$defaultDateFormat;
        }
        return $this->_dateFormat;
    }

    public function show()
    {
        $this->_visible = true;
        return $this;
    }

    public function hide()
    {
        $this->_visible = false;
        return $this;
    }

    public function isVisible()
    {
        return $this->_visible;
    }

    public function readData($item)
    {
        $accessors = array();
        if (isset($this->_options['tree']) && $this->_options['tree']) {
            $accessors = explode('.', $this->getProperty());
        }
        else {
            $accessors[] = $this->getProperty();
        }

        foreach ($accessors as $property) {
            if (is_null($item)) {
                return null;
            }
            elseif (is_array($item)) {
                $item = $item[$property];
            }
            elseif (method_exists($item, 'get'.ucfirst($property))) {
                $item = call_user_func_array(array($item, 'get'.ucfirst($property)), array());
            }
            else {
                return null;
            }
        }

        if ($item instanceOf \DateTime) {
            return $item->format($this->getDateFormat());
        }

        return $item;
    }
}<commit_msg>EOL clean up + fix for magic getters<commit_after><?php

namespace Gloomy\PagerBundle\Pager;

class Field
{
    public static $defaultDateFormat = 'Y-m-d H:i:s';

    protected $_property;

    protected $_qualifier;

    protected $_type;

    protected $_label;

    protected $_options;

    protected $_dateFormat;

    protected $_visible;

    public function __construct($property, $type = 'text', $label = '', $qualifier = null, $options = array())
    {
        $this->_property  = $property;
        $this->_type      = $type;
        $this->_label     = $label ?: ucfirst($property);
        $this->_qualifier = $qualifier ?: $property;
        $this->_options   = $options;
        $this->_visible   = true;
    }

    public function getProperty()
    {
        return $this->_property;
    }

    public function getQualifier()
    {
        return $this->_qualifier;
    }

    public function setType($type)
    {
        $this->_type = $type;
        return $this;
    }

    public function getType()
    {
        return $this->_type;
    }

    public function setLabel($label)
    {
        $this->_label = $label;
        return $this;
    }

    public function getLabel()
    {
        return $this->_label;
    }

    public function setOptions($options)
    {
        $this->_options = $options;
        return $this;
    }

    public function getOptions()
    {
        return $this->_options;
    }

    public function setDateFormat($dateFormat)
    {
        $this->_dateFormat = $dateFormat;
        return $this;
    }

    public function getDateFormat()
    {
        if (is_null($this->_dateFormat)) {
            $this->_dateFormat = self::$defaultDateFormat;
        }
        return $this->_dateFormat;
    }

    public function show()
    {
        $this->_visible = true;
        return $this;
    }

    public function hide()
    {
        $this->_visible = false;
        return $this;
    }

    public function isVisible()
    {
        return $this->_visible;
    }

    public function readData($item)
    {
        $accessors = array();
        if (isset($this->_options['tree']) && $this->_options['tree']) {
            $accessors = explode('.', $this->getProperty());
        }
        else {
            $accessors[] = $this->getProperty();
        }

        foreach ($accessors as $property) {
            if (is_null($item)) {
                return null;
            }
            elseif (is_array($item)) {
                $item = $item[$property];
            }
            else {
                if (!$item = call_user_func_array(array($item, 'get'.ucfirst($property)), array())) {
                    return null;
                }
            }
        }

        if ($item instanceOf \DateTime) {
            return $item->format($this->getDateFormat());
        }

        return $item;
    }
}
{'fraction_non_alphanumeric': 0.13269565217391305, 'fraction_numerical': 0.0, 'mean_word_length': 1.7609217474795968, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 57, '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': '1015658', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1611, 'n_words': 350}