<commit_before><?php

  namespace ActiveCollab\DatabaseConnection\Record;

  use DateTime;
  use DateTimeZone;

  /**
   * @package ActiveCollab\DatabaseConnection\Record
   */
  class ValueCaster
  {
    const CAST_INT = 'int';
    const CAST_FLOAT = 'float';
    const CAST_STRING = 'string';
    const CAST_BOOL = 'bool';
    const CAST_DATE = 'date';
    const CAST_DATETIME = 'datetime';

    private $dictated = [ 'id' => self::CAST_INT, 'row_count' => self::CAST_INT ];

    /**
     * @param array|null $dictated
     */
    public function __construct(array $dictated = null)
    {
      if ($dictated && is_array($dictated)) {
        $this->dictated = array_merge($this->dictated, $dictated);
      }
    }

    /**
     * Cast row value to native PHP types based on caster settings
     *
     * @param array $row
     */
    public function castRowValues(array &$row)
    {
      foreach ($row as $field_name => $value) {
        $row[$field_name] = $this->castValue($field_name, $value);
      }
    }

    /**
     * Cast a single value
     *
     * @param  string                                    $field_name
     * @param  mixed                                     $value
     * @return bool|DateTime|float|int|mixed|null|string
     */
    public function castValue($field_name, $value)
    {
      if ($value === null) {
        return null; // NULL remains NULL
      } else {
        switch ($this->getTypeByFieldName($field_name)) {
          case self::CAST_INT:
            return (int) $value;
          case self::CAST_FLOAT:
            return (float) $value;
          case self::CAST_STRING:
            return (string) $value;
          case self::CAST_BOOL:
            return (bool) $value;
          case self::CAST_DATE:
          case self::CAST_DATETIME:

            return new DateTime($value, new DateTimeZone('UTC'));
          default:
            return (string) $value;
        }
      }
    }

    /**
     * Return type by field name
     *
     * @param  string $field_name
     * @return string
     */<commit_msg>Cosmetic changes<commit_after><?php

  namespace ActiveCollab\DatabaseConnection\Record;

  use DateTime;
  use DateTimeZone;

  /**
   * @package ActiveCollab\DatabaseConnection\Record
   */
  class ValueCaster
  {
    const CAST_INT = 'int';
    const CAST_FLOAT = 'float';
    const CAST_STRING = 'string';
    const CAST_BOOL = 'bool';
    const CAST_DATE = 'date';
    const CAST_DATETIME = 'datetime';

    /**
     * @var array
     */
    private $dictated = [ 'id' => self::CAST_INT, 'row_count' => self::CAST_INT ];

    /**
     * @param array|null $dictated
     */
    public function __construct(array $dictated = null)
    {
      if ($dictated && is_array($dictated)) {
        $this->dictated = array_merge($this->dictated, $dictated);
      }
    }

    /**
     * Cast row value to native PHP types based on caster settings
     *
     * @param array $row
     */
    public function castRowValues(array &$row)
    {
      foreach ($row as $field_name => $value) {
        $row[$field_name] = $this->castValue($field_name, $value);
      }
    }

    /**
     * Cast a single value
     *
     * @param  string                                    $field_name
     * @param  mixed                                     $value
     * @return bool|DateTime|float|int|mixed|null|string
     */
    public function castValue($field_name, $value)
    {
      if ($value === null) {
        return null; // NULL remains NULL
      } else {
        switch ($this->getTypeByFieldName($field_name)) {
          case self::CAST_INT:
            return (int) $value;
          case self::CAST_FLOAT:
            return (float) $value;
          case self::CAST_STRING:
            return (string) $value;
          case self::CAST_BOOL:
            return (bool) $value;
          case self::CAST_DATE:
          case self::CAST_DATETIME:
            return new DateTime($value, new DateTimeZone('UTC'));
          default:
            return (string) $value;
        }
      }
    }

    /**
     * Return type by field name
     *
     * @param  string $field_name
     * @return string
     */
{'fraction_non_alphanumeric': 0.1212776176753122, 'fraction_numerical': 0.0, 'mean_word_length': 1.8763812154696133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2854176', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1221, 'n_words': 293}