<commit_before><?php
/*
| -------------------------------------------------------------------
| MATH
| -------------------------------------------------------------------
|
| Mathematical operations and calculations
|
| -------------------------------------------------------------------
*/
namespace phplibrary;

class Math {
    public static $iterator = 0;
    
    private static $bool = TRUE;
    
    // -------------------------------------------------------------------------
    
    /**
    * Calculate percentage between two numbers
    * 
    * @param int $smaller_number
    * @param int $larger_number
    * 
    * @return Array
    */
    public static function percentage($smaller_number, $larger_number)
    {
        if (empty($smaller_number) || empty($larger_number))
        {
            $percentage = 0;    
        }
        else
        {
            $percentage = (100 * $smaller_number) / $larger_number;
        }
        
        return array(
            'value' => $percentage,
            'sign'  => $percentage . '%',
        );
    }
    
    // -------------------------------------------------------------------------

    /**
    * Even or odd value return
    * 
    * @param String $value_1
    * @param String $value_2
    * 
    * @return String
    */
    public static function even_or_odd($value_1, $value_2, $bool=FALSE)
    {
        $bool ? NULL : $bool = self::$bool;
        
        self::$bool = ! self::$bool;
        
        return $bool ? $value_1 : $value_2;
    }
    
    // -------------------------------------------------------------------------
    
    /**
    * Iterates variable
    * 
    * @return void
    */
    public static function iterate()
    {
        return ++self::$iterator;
    }
    <commit_msg>Math class iterate method accepts optional bool parameter for iterator reset<commit_after><?php
/*
| -------------------------------------------------------------------
| MATH
| -------------------------------------------------------------------
|
| Mathematical operations and calculations
|
| -------------------------------------------------------------------
*/
namespace phplibrary;

class Math {
    public static $iterator = 0;
    
    private static $bool = TRUE;
    
    // -------------------------------------------------------------------------
    
    /**
    * Calculate percentage between two numbers
    * 
    * @param int $smaller_number
    * @param int $larger_number
    * 
    * @return Array
    */
    public static function percentage($smaller_number, $larger_number)
    {
        if (empty($smaller_number) || empty($larger_number))
        {
            $percentage = 0;    
        }
        else
        {
            $percentage = (100 * $smaller_number) / $larger_number;
        }
        
        return array(
            'value' => $percentage,
            'sign'  => $percentage . '%',
        );
    }
    
    // -------------------------------------------------------------------------

    /**
    * Even or odd value return
    * 
    * @param String $value_1
    * @param String $value_2
    * 
    * @return String
    */
    public static function even_or_odd($value_1, $value_2, $bool=FALSE)
    {
        $bool ? NULL : $bool = self::$bool;
        
        self::$bool = ! self::$bool;
        
        return $bool ? $value_1 : $value_2;
    }
    
    // -------------------------------------------------------------------------
    
    /**
    * Iterates variable
    * 
    * @param Bool $to_reset
    * 
    * @return void
    */
    public static function iterate($to_reset=FALSE)
    {
        $to_reset ? self::$iterator = 0 : NULL;
        
        return ++self::$iterator;
    }
    
{'fraction_non_alphanumeric': 0.3191832348199892, 'fraction_numerical': 0.006179473401397098, 'mean_word_length': 0.9043478260869565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3899036', 'n_tokens_mistral': 927, 'n_tokens_neox': 907, 'n_words': 199}