<commit_before><?php
/**
* This file is part of the MathExecutor package
*
* (c) <NAME>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code
*/

namespace NXP\Classes\Token;

/**
* @author <NAME> <<EMAIL>>
*/
class TokenDivision extends AbstractOperator
{
    /**
     * @return string
     */
    public static function getRegex()
    {
        return '\/';
    }

    /**
     * @return int
     */
    public function getPriority()
    {
        return 2;
    }

    /**
     * @return string
     */
    public function getAssociation()
    {
        return self::LEFT_ASSOC;
    }

    /**
     * @param InterfaceToken[] $stack
     * @return $this
     */
    public function execute(&$stack)
    {
        $op2 = array_pop($stack);
        $op1 = array_pop($stack);
        $result = $op1->getValue() / $op2->getValue();

        return new TokenNumber($result);
    }
}<commit_msg>Avoid division by zero<commit_after><?php
/**
* This file is part of the MathExecutor package
*
* (c) <NAME>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code
*/

namespace NXP\Classes\Token;

/**
* @author <NAME> <<EMAIL>>
*/
class TokenDivision extends AbstractOperator
{
    /**
     * @return string
     */
    public static function getRegex()
    {
        return '\/';
    }

    /**
     * @return int
     */
    public function getPriority()
    {
        return 2;
    }

    /**
     * @return string
     */
    public function getAssociation()
    {
        return self::LEFT_ASSOC;
    }

    /**
     * @param InterfaceToken[] $stack
     * @return $this
     */
    public function execute(&$stack)
    {
        $op2 = array_pop($stack);
        $op1 = array_pop($stack);
        $result = $op2->getValue() > 0 ? $op1->getValue() / $op2->getValue() : 0;

        return new TokenNumber($result);
    }
}
{'fraction_non_alphanumeric': 0.13673469387755102, 'fraction_numerical': 0.0066326530612244895, 'mean_word_length': 2.147672552166934, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, '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': '5886519', 'n_tokens_mistral': 603, 'n_tokens_neox': 585, 'n_words': 162}