<commit_before><?php
# Copyright (C) 2017, 2018 <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

/**
 * This class handles a database table result
 *
 * Very often this database table has an ID and an UID.
 */
class Queried {

	/**
	 * Maximum UID length
	 */
	const MAXLEN_UID = 256;

	/**
	 * Empty constructor
	 */
	public function __construct() {}

	/**
	 * Obtain a property that can be null (but can't be undefined).
	 *
	 * @param string $property
	 * @return mixed
	 */
	public function get( $property ) {
		if( property_exists( $this, $property ) ) {
			return $this->$property;
		}
		error_die( sprintf(
			'cannot obtain %s->%s',
			get_class( $this ),
			$property
		) );
	}

	/**
	 * Check if a property is not NULL
	 *
	 * @param string $property
	 * @return bool
	 */
	public function has( $property ) {
		return null !== $this->get( $property );
	}

	/**
	 * Obtain a property that can't be null (and can't be undefined).
	 *
	 * @param string $property
	 * @return mixed
	 */
	public function nonnull($property) {
		if( isset( $this->$property ) ) {
			return $this->$property;
		}
		error_die( sprintf(
			'cannot obtain %s->%s',
			get_class( $this ),
			$property
		) );
	}

	function integers() {
		foreach( func_get_args() as $p) {
			isset( $this->$p ) and
				$this->$p = (int) $this->$p;
		}
		return $this;
	}

	function booleans() {
		foreach( func_get_args() as $p) {
			isset( $this->$p ) and
				$this->$p = (bool) (int) $this->$p;
		}
		return $this;
	}<commit_msg>throw Exeption on Queried errors<commit_after><?php
# Copyright (C) 2017, 2018, 2019 <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

/**
 * This class handles a database table result
 *
 * Very often this database table has an ID and an UID.
 */
class Queried {

	/**
	 * Maximum UID length
	 */
	const MAXLEN_UID = 256;

	/**
	 * Empty constructor
	 */
	public function __construct() {}

	/**
	 * Obtain a property that can be null (but can't be undefined).
	 *
	 * @param string $property
	 * @return mixed
	 */
	public function get( $property ) {
		if( property_exists( $this, $property ) ) {
			return $this->$property;
		}
		throw new Exception( sprintf(
			'cannot obtain %s->%s',
			get_class( $this ),
			$property
		) );
	}

	/**
	 * Check if a property is not NULL
	 *
	 * @param string $property
	 * @return bool
	 */
	public function has( $property ) {
		return null !== $this->get( $property );
	}

	/**
	 * Obtain a property that can't be null (and can't be undefined).
	 *
	 * @param string $property
	 * @return mixed
	 */
	public function nonnull($property) {
		if( isset( $this->$property ) ) {
			return $this->$property;
		}
		throw new Exception( sprintf(
			'cannot obtain %s->%s',
			get_class( $this ),
			$property
		) );
	}

	function integers() {
		foreach( func_get_args() as $p) {
			isset( $this->$p ) and
				$this->$p = (int) $this->$p;
		}
		return $this;
	}

	function booleans() {
		foreach( func_get_args() as $p) {
			isset( $this->$p ) and
				$this->$p = (bool) (int) $this->$p;
		}
		return $this;
	}
{'fraction_non_alphanumeric': 0.12893304944405015, 'fraction_numerical': 0.006624083274189733, 'mean_word_length': 3.120857699805068, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2176682', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1327, 'n_words': 515}