<commit_before><?php
/******************************************************************************
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
 * 
 * Copyright (c) 2016 <NAME> <<EMAIL>>
 *
 * This software is licensed under The MIT License. You should have received 
 * a copy of the along with the code.
 */

namespace Lechimp\Dicto;

class Dicto {
    private function __construct() {}

    static private $rt = null;

    /**
     * Discard the current definition if there is any.
     */
    public static function discardDefinition() {
        self::$rt = null; 
    }

    /**
     * Start the definition of a new ruleset.
     *
     * @throws  \RuntimeException   if definition was already started
     */
    public static function startDefinition() {
        if (self::$rt !== null) {
            throw new \RuntimeException("Already started a rule definition");
        }
        self::$rt = new Definition\RuleDefinitionRT();
    }

    /**
     * Discard the current definition if there is any.
     *
     * @throws  \RuntimeException   if definition was not started or already ended
     */
    public static function endDefinition() {
        if (self::$rt === null) {
            throw new \RuntimeException("Already ended or not even started the rule definition");
        }
        $rule_set = self::$rt->ruleset();
        self::discardDefinition();
        return $rule_set;
    }

    /**
     * Define a only-rule.
     *
     * @throws  \RuntimeException   if previous variable declaration has not finished
     * @throws  \RuntimeException
     * @return  Fluid\Only
     */
    public static function only() {
        if (self::$rt === null) {
            throw new \RuntimeException(
                "No variable definition allowed outside ruleset definition.");
        }
        return self::$rt->only();
    }

    /**
     * Define a new variable or reference an already defined variable to define
     * a rule.
     *
     * @throws  \InvalidArgumentException   if $arguments are passed
     * @throws  \RuntimeException           if previous variable declaration was not finished
     * @throws  \RuntimeException           if definition was not started 
     * @return  NewVar|RuleVar
     */
    public static function __callStatic($name, $arguments) {
        # ToDo: This is used in Definition\Fluid\Means as well.
        if (count($arguments) != 0) {
            throw new \InvalidArgumentException(
                "No arguments are allowed for definition of ".
                "or reference to variable.");
        } 
        if (self::$rt === null) {
            throw new \RuntimeException(
                "No variable definition allowed outside ruleset definition.");
        }
        return self::$rt->variable($name);
    }
}
<commit_msg>removed whitespace<commit_after><?php
/******************************************************************************
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
 * 
 * Copyright (c) 2016 <NAME> <<EMAIL>>
 *
 * This software is licensed under The MIT License. You should have received 
 * a copy of the along with the code.
 */

namespace Lechimp\Dicto;

class Dicto {
    private function __construct() {}

    static private $rt = null;

    /**
     * Discard the current definition if there is any.
     */
    public static function discardDefinition() {
        self::$rt = null; 
    }

    /**
     * Start the definition of a new ruleset.
     *
     * @throws  \RuntimeException   if definition was already started
     */
    public static function startDefinition() {
        if (self::$rt !== null) {
            throw new \RuntimeException("Already started a rule definition");
        }
        self::$rt = new Definition\RuleDefinitionRT();
    }

    /**
     * Discard the current definition if there is any.
     *
     * @throws  \RuntimeException   if definition was not started or already ended
     */
    public static function endDefinition() {
        if (self::$rt === null) {
            throw new \RuntimeException("Already ended or not even started the rule definition");
        }
        $rule_set = self::$rt->ruleset();
        self::discardDefinition();
        return $rule_set;
    }

    /**
     * Define a only-rule.
     *
     * @throws  \RuntimeException   if previous variable declaration has not finished
     * @throws  \RuntimeException
     * @return  Fluid\Only
     */
    public static function only() {
        if (self::$rt === null) {
            throw new \RuntimeException(
                "No variable definition allowed outside ruleset definition.");
        }
        return self::$rt->only();
    }

    /**
     * Define a new variable or reference an already defined variable to define
     * a rule.
     *
     * @throws  \InvalidArgumentException   if $arguments are passed
     * @throws  \RuntimeException           if previous variable declaration was not finished
     * @throws  \RuntimeException           if definition was not started 
     * @return  NewVar|RuleVar
     */
    public static function __callStatic($name, $arguments) {
        # ToDo: This is used in Definition\Fluid\Means as well.
        if (count($arguments) != 0) {
            throw new \InvalidArgumentException(
                "No arguments are allowed for definition of ".
                "or reference to variable.");
        }
        if (self::$rt === null) {
            throw new \RuntimeException(
                "No variable definition allowed outside ruleset definition.");
        }
        return self::$rt->variable($name);
    }
}

{'fraction_non_alphanumeric': 0.12366737739872068, 'fraction_numerical': 0.0017768301350390902, 'mean_word_length': 2.1856253537068477, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5471557', 'n_tokens_mistral': 1428, 'n_tokens_neox': 1389, 'n_words': 501}