<commit_before><?php

namespace EE\Model;

use EE;

/**
 * Base EE Model class.
 */
abstract class Base {

	/**
	 * @var string Table that current model will write to
	 */
	protected static $table;

	/**
	 * @var string Primary key of current model
	 */
	protected static $primary_key;

	/**
	 * @var string It will contain an array of all fields that are present in database in table
	 */
	protected $fields;

	/**
	 * Base constructor.
	 *
	 * @param array $fields Array of fields containing fields from database
	 */
	public function __construct( array $fields = [] ) {
		$this->fields = $fields;
	}

	/**
	 * Throws exception if model is not found
	 *
	 * @param string $value  value to find
	 * @param string $column Column to find in. Defaults to primary key
	 *
	 * @throws \Exception
	 *
	 * @return static
	 */
	public static function find_or_fail( string $value, string $column = null ) {
		$model = static::find( $value, $column );

		if ( ! $model ) {
			throw new \Exception( sprintf( 'Unable to find %s : with primary key: %s and value: %s', __CLASS__, static::$primary_key, $value ) );
		}

		return $model;
	}

	/**
	 * Returns single model fetched by primary key
	 *
	 * @param string $value  value to find
	 * @param string $column Column to find in. Defaults to primary key
	 *
	 * @throws \Exception
	 *
	 * @return bool|static
	 */
	public static function find( string $value, string $column = null ) {
		$primary_key_column = $column ?? static::$primary_key;
		$model              = EE::db()
			->table( static::$table )
			->where( $primary_key_column, $value )
			->first();

		if ( false === $model ) {
			return false;
		}

		return static::single_array_to_model( $model );
	}

	/**
	 * Converts single row fetched from database into model
	 *
	 * @param array $arr Associative array representing a row from database
	 *
	 * @return mixed
	 */
	protected static function single_array_to_model( array $arr ) {
		return new static( $arr );
	}
<commit_msg>Change find() method to select columns<commit_after><?php

namespace EE\Model;

use EE;

/**
 * Base EE Model class.
 */
abstract class Base {

	/**
	 * @var string Table that current model will write to
	 */
	protected static $table;

	/**
	 * @var string Primary key of current model
	 */
	protected static $primary_key;

	/**
	 * @var string It will contain an array of all fields that are present in database in table
	 */
	protected $fields;

	/**
	 * Base constructor.
	 *
	 * @param array $fields Array of fields containing fields from database
	 */
	public function __construct( array $fields = [] ) {
		$this->fields = $fields;
	}

	/**
	 * Throws exception if model is not found
	 *
	 * @param string $value  value to find
	 * @param string $column Column to find in. Defaults to primary key
	 *
	 * @throws \Exception
	 *
	 * @return static
	 */
	public static function find_or_fail( string $value, string $column = null ) {
		$model = static::find( $value, $column );

		if ( ! $model ) {
			throw new \Exception( sprintf( 'Unable to find %s : with primary key: %s and value: %s', __CLASS__, static::$primary_key, $value ) );
		}

		return $model;
	}

	/**
	 * Returns single model fetched by primary key
	 *
	 * @param string $value        value to find
	 * @param array  $columns      Columns to select.
	 *
	 * @throws \Exception
	 *
	 * @return bool|static
	 */
	public static function find( string $value, array $columns = [] ) {

		$model = EE::db()
			->table( static::$table )
			->select( ...$columns )
			->where( static::$primary_key, $value )
			->first();

		if ( false === $model ) {
			return false;
		}

		return static::single_array_to_model( $model );
	}

	/**
	 * Converts single row fetched from database into model
	 *
	 * @param array $arr Associative array representing a row from database
	 *
	 * @return mixed
	 */
	protected static function single_array_to_model( array $arr ) {
		return new static( $arr );
	}

{'fraction_non_alphanumeric': 0.12194501018329938, 'fraction_numerical': 0.0, 'mean_word_length': 3.0173824130879345, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, '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': '5861907', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1151, 'n_words': 440}