<commit_before><?php
namespace DrdPlus\Tables\History;

use DrdPlus\Codes\FateCode;
use DrdPlus\Tables\Partials\AbstractFileTable;
use DrdPlus\Tables\Partials\Exceptions\RequiredColumnNotFound;
use DrdPlus\Tables\Partials\Exceptions\RequiredRowNotFound;
use Granam\Integer\Tools\ToInteger;
use Granam\Tools\ValueDescriber;

class InfluenceOfFortuneTable extends AbstractFileTable
{
    /**
     * @return string
     */
    protected function getDataFileName()
    {
        return __DIR__ . '/data/influence_of_fortune.csv';
    }

    const PRIMARY_PROPERTY_ON_1 = 'primary_property_on_1';
    const SECONDARY_PROPERTY_ON_1 = 'secondary_property_on_1';
    const PRIMARY_PROPERTY_ON_2 = 'primary_property_on_2';
    const SECONDARY_PROPERTY_ON_2 = 'secondary_property_on_2';
    const PRIMARY_PROPERTY_ON_3 = 'primary_property_on_3';
    const SECONDARY_PROPERTY_ON_3 = 'secondary_property_on_3';
    const PRIMARY_PROPERTY_ON_4 = 'primary_property_on_4';
    const SECONDARY_PROPERTY_ON_4 = 'secondary_property_on_4';
    const PRIMARY_PROPERTY_ON_5 = 'primary_property_on_5';
    const SECONDARY_PROPERTY_ON_5 = 'secondary_property_on_5';
    const PRIMARY_PROPERTY_ON_6 = 'primary_property_on_6';
    const SECONDARY_PROPERTY_ON_6 = 'secondary_property_on_6';

    /**
     * @return array|string[]
     */
    protected function getExpectedDataHeaderNamesToTypes()
    {
        return [
            self::PRIMARY_PROPERTY_ON_1 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_1 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_2 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_2 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_3 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_3 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_4 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_4 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_5 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_5 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_6 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_6 => self::POSITIVE_INTEGER,
        ];
    }

    const FATE = 'fate';

    /**
     * @return array|string[]
     */
    protected function getRowsHeader()
    {
        return [self::FATE];
    }

    /**
     * @param FateCode $fateCode
     * @param int $diceRoll
     * @return int
     * @throws \DrdPlus\Tables\History\Exceptions\UnexpectedDiceRoll
     */
    public function getPrimaryPropertyOnFate(FateCode $fateCode, $diceRoll)
    {
        try {
            /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
            return $this->getValue($fateCode, 'primary_property_on_' . ToInteger::toPositiveInteger($diceRoll));
        } catch (RequiredColumnNotFound $requiredColumnNotFound) {
            throw new Exceptions\UnexpectedDiceRoll('Expected roll from 1 to 6, got ' . ValueDescriber::describe($diceRoll));
        }
    }

    /**
     * @param FateCode $fateCode
     * @param int $diceRoll
     * @return int
     * @throws \DrdPlus\Tables\History\Exceptions\UnexpectedDiceRoll
     */
    public function getSecondaryPropertyOnFate(FateCode $fateCode, $diceRoll)
    {
        try {
            /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
            return $this->getValue($fateCode, 'secondary_property_on_' . ToInteger::toPositiveInteger($diceRoll));
        } catch (RequiredColumnNotFound $requiredColumnNotFound) {
            throw new Exceptions\UnexpectedDiceRoll('Expected roll from 1 to 6, got ' . ValueDescriber::describe($diceRoll));
        }
    }

}<commit_msg>Roll can be given as integer interface by annotation<commit_after><?php
namespace DrdPlus\Tables\History;

use DrdPlus\Codes\FateCode;
use DrdPlus\Tables\Partials\AbstractFileTable;
use DrdPlus\Tables\Partials\Exceptions\RequiredColumnNotFound;
use Granam\Integer\IntegerInterface;
use Granam\Integer\Tools\ToInteger;
use Granam\Tools\ValueDescriber;

class InfluenceOfFortuneTable extends AbstractFileTable
{
    /**
     * @return string
     */
    protected function getDataFileName()
    {
        return __DIR__ . '/data/influence_of_fortune.csv';
    }

    const PRIMARY_PROPERTY_ON_1 = 'primary_property_on_1';
    const SECONDARY_PROPERTY_ON_1 = 'secondary_property_on_1';
    const PRIMARY_PROPERTY_ON_2 = 'primary_property_on_2';
    const SECONDARY_PROPERTY_ON_2 = 'secondary_property_on_2';
    const PRIMARY_PROPERTY_ON_3 = 'primary_property_on_3';
    const SECONDARY_PROPERTY_ON_3 = 'secondary_property_on_3';
    const PRIMARY_PROPERTY_ON_4 = 'primary_property_on_4';
    const SECONDARY_PROPERTY_ON_4 = 'secondary_property_on_4';
    const PRIMARY_PROPERTY_ON_5 = 'primary_property_on_5';
    const SECONDARY_PROPERTY_ON_5 = 'secondary_property_on_5';
    const PRIMARY_PROPERTY_ON_6 = 'primary_property_on_6';
    const SECONDARY_PROPERTY_ON_6 = 'secondary_property_on_6';

    /**
     * @return array|string[]
     */
    protected function getExpectedDataHeaderNamesToTypes()
    {
        return [
            self::PRIMARY_PROPERTY_ON_1 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_1 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_2 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_2 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_3 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_3 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_4 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_4 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_5 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_5 => self::POSITIVE_INTEGER,
            self::PRIMARY_PROPERTY_ON_6 => self::POSITIVE_INTEGER,
            self::SECONDARY_PROPERTY_ON_6 => self::POSITIVE_INTEGER,
        ];
    }

    const FATE = 'fate';

    /**
     * @return array|string[]
     */
    protected function getRowsHeader()
    {
        return [self::FATE];
    }

    /**
     * @param FateCode $fateCode
     * @param int $diceRoll
     * @return int
     * @throws \DrdPlus\Tables\History\Exceptions\UnexpectedDiceRoll
     */
    public function getPrimaryPropertyOnFate(FateCode $fateCode, $diceRoll)
    {
        try {
            /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
            return $this->getValue($fateCode, 'primary_property_on_' . ToInteger::toPositiveInteger($diceRoll));
        } catch (RequiredColumnNotFound $requiredColumnNotFound) {
            throw new Exceptions\UnexpectedDiceRoll('Expected roll from 1 to 6, got ' . ValueDescriber::describe($diceRoll));
        }
    }

    /**
     * @param FateCode $fateCode
     * @param int|IntegerInterface $diceRoll
     * @return int
     * @throws \DrdPlus\Tables\History\Exceptions\UnexpectedDiceRoll
     */
    public function getSecondaryPropertyOnFate(FateCode $fateCode, $diceRoll)
    {
        try {
            /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
            return $this->getValue($fateCode, 'secondary_property_on_' . ToInteger::toPositiveInteger($diceRoll));
        } catch (RequiredColumnNotFound $requiredColumnNotFound) {
            throw new Exceptions\UnexpectedDiceRoll('Expected roll from 1 to 6, got ' . ValueDescriber::describe($diceRoll));
        }
    }

}
{'fraction_non_alphanumeric': 0.09685197588747488, 'fraction_numerical': 0.010716677829872739, 'mean_word_length': 3.511178247734139, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '3101388', 'n_tokens_mistral': 2399, 'n_tokens_neox': 2394, 'n_words': 354}